Garbage Collector

Zenerdiode

Active Member
Licensed User
We often hear about concerns of memory usage with Basic4PPC - and then get assurances from Erel and agraham that if its not causing 'Out of Memory' exceptions; just forget about it and leave the GC alone. In fact, without using Door, there's not an easy way to force a GC on the desktop.

My attached program demonstrates this. Every timer tick, two new pie chart objects are created. So after assigning the pie object to the image, I tried to dispose of the pie. Of course the next timer tick complains because the object is no longer there. So I then used an AddObject in the Tick sub, but this time even though I had disposed of the pie; I then had an exception that I was trying to add an object thats already there.

So I just let the program run as is (its to show progress of a ROBOCOPY script, copying between two drives) and was watching memory useage in Task Manager, increase with each tick. It does so, in the order of 100-200M but then drops down to 20M again. I assume this is the GC doing its job?
 

agraham

Expert
Licensed User
Longtime User
I then used an AddObject in the Tick sub, but this time even though I had disposed of the pie; I then had an exception that I was trying to add an object thats already there.
It should have worked, this does -
B4X:
   PieChart1.Dispose
   AddObject("PieChart1", "PieChart")
   PieChart1.New1(300,300)

I assume this is the GC doing its job?
Highly likely.
 
Top