Click to See Complete Forum and Search --> : Out of Memory - Forms


itehab
August 29th, 2001, 03:16 AM
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.

Andrew_Fryer
August 29th, 2001, 03:20 AM
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.

itehab
August 29th, 2001, 05:41 AM
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

sotoasty
August 29th, 2001, 09:46 AM
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

Cimperiali
August 29th, 2001, 10:02 AM
>, 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