TotalCross / totalcross

TotalCross is a Software Development Kit that helps cross platform application development. Currently supported platforms are: Windows, Wince, Android, iOS, Linux and Linux ARM for embedded systems.
https://www.totalcross.com
GNU Lesser General Public License v2.1
220 stars 40 forks source link

Garbage Collector not firing when removing elements from a List Container #326

Open VicMisael opened 3 years ago

VicMisael commented 3 years ago

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

jeffque commented 3 years ago

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.