UnderwaterApps / overlap2d-runtime-libgdx

Overlap2D - UI and Level Editor libgdx runtime
http://overlap2d.com
Other
170 stars 96 forks source link

Fixed a memory leak caused by CompositeItem.itemLayerMap holding a #24

Closed ThaBalla1148 closed 9 years ago

ThaBalla1148 commented 9 years ago

Fixed a memory leak caused by CompositeItem.itemLayerMap holding a reference to the IBaseItem being removed from the parent item.

azakhary commented 9 years ago

Thanks for finding this!, will get it merged, but I also wanted to add that as general rule, you want to avoid usage of addItem removeItem on the fly. I mean you can do it but not too much as it is a slow operation, and if you need to add and remove a lot, then maybe consider using addActor instead.

ThaBalla1148 commented 9 years ago

Hello, thanks for accepting my pull request and your recommendation. I will try using the following for adding and removing dynamic items from the scene (i.e. bullets):

Adding:

CompositeItem item = sceneLoader.getLibraryAsActor(libraryItemName);
sceneLoader.getRoot().addActor(item);

Removing:

item.remove();