Free memory

K

Keven Corazza

Hi, I'm usign CF 1.0 and I'm really confused about memory management of CF.

Imagine this situation:

- a form, memory free about 6 Mb
- a form open a new form
- the new form has a list view and 1000 items are added to it
- memory free about 2 Mb
- the new form is closed; I call dispose method.
- memory free 2 Mb

If I open the second form a second one I have no memory to continue and I
get the message "Program memory is very low...."

What I have to do to free memory ?

I know that GC free the memory (?) automatically but perhaps it is necessary
sometimes to tell him to start to do it.

Thank you in advance for your help.

Keven Corazza
 
C

Chris Tacke, eMVP

The GC doesn't automatically "free memory". You need to really understand
how it works. When you Dispose the Form, it is marked as available for
collection (assuming it has no other roots). The controls in it also get
Diposed and similarly marked.

The next time collection happeds, these items will be freed. This means
that the space is now available in the GC Heap *not necessarily* to the OS.
The only way it will be available to the OS is if the GC thendoes a
compaction and frees some memory segments from the GC heap.

I highly recommend that you watch the MSDN web cast on Compact Framework
Memory Management.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
 
M

Markus Humm

Hello,

if I understand you correctly you have:

1. a main form
2. you open another form from it and then still have 6 MB RAM
3. you open yet another form from the 2nd one and then only
have 2 MB left
4. now you close the 3rd form
5. you still have only 2 MB left
6. you try to create another form but it fails due to not
enough free memory.

So either CF does something bad and doesn't reuse the 4 MB which should
be free after you closed the 3rd form or there's still some reference to
that data from your listview or the 4th form to be opened needs more
than 6 MB.

Could you please clarify this?

Greetings

Markus
 
A

Alessandro

HI.
I have the same problem with CF1.0 and listview. Have you found a solution ?
Thanks
Alessandro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top