Results 1 to 4 of 4

Thread: 'System.OutOfMemoryException' UGH!

  1. #1

    Thread Starter
    Fanatic Member Geespot's Avatar
    Join Date
    Oct 2001
    Location
    Birmingham, UK
    Posts
    577

    'System.OutOfMemoryException' UGH!

    im creating just a simple MDI app and to add a child window i use this code..

    Dim NewMDIChild As New Form2()
    NewMDIChild.MdiParent = Me
    NewMDIChild.Show()

    and it worked, but after a bit i got an error

    An unhandled exception of type 'System.OutOfMemoryException' occurred in system.windows.forms.dll

    Additional information: Error creating window handle.


    Now im guessing i am not freeing up my childs after i create and close them, because of the OutOfMemoryException part.

    If this is the case, how do i free them when the app closes?


    P.S Side question
    I would like
    Dim NewMDIChild As New Form2()
    NewMDIChild.MdiParent = Me
    NewMDIChild.Show()
    in a module, but if i change the

    newmdichild.mdiparent = me to
    newmdichild.mdiparent = Form2

    it doesnt work, how can i do this?

    thanks

  2. #2
    New Member blue_rabbit's Avatar
    Join Date
    May 2004
    Location
    Behind enemy lines
    Posts
    9

    Lightbulb

    >P.S Side question
    >I would like
    >Dim NewMDIChild As New Form2()
    >NewMDIChild.MdiParent = Me
    >NewMDIChild.Show()
    >in a module, but if i change the

    >newmdichild.mdiparent = me to
    >newmdichild.mdiparent = Form2

    >it doesnt work, how can i do this?
    >thanks

    I recently ran into this problem as well, if you create a Public variable of type Form2 and then in Form2_Load assign a reference to Form2 to that variable, you should be able to access it no problem.

    here's what i'm talking about

    [in Module1.vb]
    Public myForm1 as Form1 'this variable will be accesible to the whole project

    [in Form1.vb]
    Private Sub Form1_Load(blah, blah blah)
    myForm1=me
    End Sub


    Now whenever you want to access Form1's properties and furthermore the controls contained therein, instead of using Form1 as the variable, use the reference stored in myForm1. I think that should solve your problem.
    //END_TRANSMISSION

  3. #3

    Thread Starter
    Fanatic Member Geespot's Avatar
    Join Date
    Oct 2001
    Location
    Birmingham, UK
    Posts
    577
    Thanks

    But this question is two years old
    Infact, can't even remember the question. Ohwell useful for archive purposes

  4. #4
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    I'm getting this same exception, with the "error creating window handle" message, and I can't figure out why. This is C#, but the code is easy to read.

    When I had this code in the constructor, the MDI child form shows just fine
    PHP Code:
                Tables t = new Tables(); // Tables is a Windows form
                
    t.MdiParent this;
                
    t.Show(); 
    But when I put the same exact code in the method that executes when you click a button, I get the OutOfMemoryException
    PHP Code:
            private void miServerData_Click(object senderSystem.EventArgs e)
            {
                
    Tables t = new Tables(); // Tables is a Windows form
                
    t.MdiParent this;
                
    t.Show(); // Error on this line
            

    I'm trying to track it down, can anyone help?

    Thanks,
    Mike

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width