totalcross icon indicating copy to clipboard operation
totalcross copied to clipboard

Garbage Collector not firing when removing elements from a List Container

Open VicMisael opened this issue 3 years ago • 1 comments

Describe the bug

RemoveAllContainers() on List Container does not free memory

Devices:

Please complete the following information: Any device but not the simulator

To Reproduce

SQLiteteste.zip Use this application, and click on populate list view,and then click remove all from list view

Screenshots or videos

When the elements were added image When all containers are removed and Vm.gc() is called image

VicMisael avatar Mar 31 '21 13:03 VicMisael

So, the usage of ListContainer as I could seen is to add items with addContainer, not plain add (check this and this).

Internally, adding stuff to a ListContainer via it's traditional addContainer method causes a push in the Vector vc field. Calling the traditional ListContainer.removeAllContainers() will call the vc.removeAllElements() method in the Vector. This method just marks all the elements in the Vector as null and does not attempt to free the inner array Object items[]. So the results of calling the gc in this case may not be as effective as you might expect.

jeffque avatar May 11 '21 11:05 jeffque