Memory doesn't release (from collections)

  • Thread starter Thread starter Brian Mitchell
  • Start date Start date
B

Brian Mitchell

Hello, I am using several queue collections to store some data (about 20,000
entries split across 2 collections). When I view the process in the Windows
task manager I can see the memory increasing when the collections start to
fill. However, when I stop the thread and clear the queues (and set the
instance to nothing) the memory does not drop at all.

Am I doing something wrong?

Thanks!!
 
Just because an object is eligible for garbage collection, doesn't mean it
gets garbage collected right away.

When the garbage collector decides to run, then anything eligible will get
collected. Until then it will sit there taking up memory.
 
is there a way to "force" garbage collection?

Marina said:
Just because an object is eligible for garbage collection, doesn't mean it
gets garbage collected right away.

When the garbage collector decides to run, then anything eligible will get
collected. Until then it will sit there taking up memory.
 
Yes, you can use gc.collect but no matter I let the program sit for 2 hours
and it still didn't free the memory. I even set a breakpoint to make sure
the class was set to nothing.
 
I believe one of the criteria for the Garbage Collector to run is the need
for memory space. If you have plenty of memory space, it may be that the
Garbage Collector doesn't think it needs to run. You might try running
another application that take a lot of memory to see if it releases some
memory.
 
Dave,

There are two criteria to let a object get removed by the garbage collector.
1 it has itself no reference anymore
2 there is not any reference anymore to it

Private myarraylist1 as new arraylist
sub mysub
dim myarraylist2 as new arraylist
myarraylist.add(myarraylist2)
end sub

Although mysub goes out of scope and myarraylist2 is automaticly nothing,
will it not be removed as long as myarralist1 exist.

I hope this helps?

Cor
 
Back
Top