Why does LoadPicture use lots of memory

jdrogan

Member
Licensed User
Hi,
I'm sure this is a n00b question but why does multiple clicks of the button in this code run memory up? It's like memory isn't released after each execution.
blank.gif is a "blank" gif of 2.33KB

Sub App_Start
Form1.Show
Image1.LoadPicture("blank.gif")
End Sub


Sub Button1_Click
Image1.LoadPicture("blank.gif")
Image1.LoadPicture("blank.gif")
Image1.LoadPicture("blank.gif")
Image1.LoadPicture("blank.gif")
Image1.LoadPicture("blank.gif")
Image1.LoadPicture("blank.gif")
Image1.LoadPicture("blank.gif")
Image1.LoadPicture("blank.gif")
Image1.LoadPicture("blank.gif")
Image1.LoadPicture("blank.gif")
Return
End Sub
 

jdrogan

Member
Licensed User
Thanks for the reply.
That's the problem, the app runs out of memory after 1 or 2 clicks on my ppc.
On the pc it's not a real issue (4g etc.).

Is there a way to force the garbage collector to run?

GCCollect in my code just gives a compile error (it thinks CGCollect is a variable)

Alternatively, is there a way to programmactically make an image visible/invisible? :sign0104:
 

agraham

Expert
Licensed User
Longtime User
As you didn't post blank.gif I have no idea how big the picture it represents is, but just because the gif is small it doesn't mean the resulting bitmap is. One problem is that the .NET grabage collector thinks that a Bitmap is small because it only takes up a tiny amount of managed memory, but you are probably running out of conventional memory which is where the real bitmap memory is allocated.

Out of interest how are you managing to compile your application with what I assume is the trial version as you don't appear to be a registered user?
 

jdrogan

Member
Licensed User
Compiling:
I'm a licensed member (sent a note to support to get my forum status changed).

I get it now. The "small" gif was really 2 meg and was running out of conventional memory. Works great now.

Thanks:)
 
Top