CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2001
    Posts
    5

    Out of Memory - Forms

    Hello,

    I have a very long MDI child form, I have implemented this by using a picture box on a Form. In this picture box I have lots of labels, text boxes and a few flexgrid controls. Basically there one label array and one text box array, but within each array there are a few hunderd controls.

    Now the problem is that why I run this application and try to open this form, I get a "Out of Memory" message. The application compiles and all other smaller forms work properly.

    Has anyone encountered something like this and is there a clean solution or atleast a work around for this?

    Thank you

    PS: Because of the application requirements, I cant break this one huge form into multiple forms.


  2. #2
    Join Date
    Aug 2000
    Location
    England
    Posts
    185

    Re: Out of Memory - Forms

    Have you tried closing any other open forms - I had a similar problem and that seemed to helps. In addition global variables especially arrays use a lot of memory so trying using local ones wherever possible.


  3. #3
    Join Date
    May 2001
    Posts
    5

    Re: Out of Memory - Forms

    Hello Andrew,

    I dont have any other form open, while opening this big form and I dont have any global variable arrays, just a couple of string global variable.

    I dont think this has anything to do with the available system resources, as I encounter the same problem with 32, 64 and 128 MB RAM - PII and PIII systems, running Windows 95/98.

    Thank you

    Regards


  4. #4
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,452

    Re: Out of Memory - Forms

    You may not like this solution and it might not work, but here goes. First, save a copy of your form for backup purposes. Next, Delete all of the labels off of the picture box. Run your form to see if you are still getting the out of memory error. If you do, this solution won't work. If the out of memory error does not show up, you will have to label everything through code. Do it like this.

    <vbcode>
    Option Explicit
    Private Loading As Boolean

    Private Sub Form_Activate()

    If Loading Then
    Picture1.Cls
    Picture1.CurrentX = 50
    Picture1.CurrentY = 50
    Picture1.Print "First Label"
    Picture1.CurrentX = 250
    Picture1.CurrentY = 250
    Picture1.Print "Second Label"
    Picture1.CurrentX = 450
    Picture1.CurrentY = 450
    Picture1.Print "Third Label"
    Loading = False
    End If

    End Sub

    Private Sub Form_Load()

    Loading = True

    End Sub

    </vbcode>

    Yes this will be a real pain in the @#$. The only other way I can think of at the moment will be to break things up into different forms.

    Hope this helps


  5. #5
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Out of Memory - Forms

    >, but within each array there are a few hunderd controls.
    Do you mean you made an array of -say- 200 textboxes? Like text1(0) to text
    (199)? How can you make all those control to be visible at same time?

    Maybe you can:
    a)use the Datarepeater control (=Microsoft DataRepeater control)
    b)use only as many controls as you can show, and recycle them when need
    to show other informations

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

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

Featured