Skip to content

PApplet fragments remain in memory even after parent activity has been destroyed #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jsalerno opened this issue May 12, 2016 · 4 comments
Assignees

Comments

@jsalerno
Copy link

A fix in #213 solved the issue of Activity refs being retained by PApplet fragments. That solves a major part of memory loss/leakage. Those activity's PApplet fragments, however, are themselves retained in memory even after the Activity instances are gone from the Heap.

Here is a sample reference tree of such a fragment ref still on the heap:

mypkg.MyTroublesomeProcessingFragment@317856864 (0x12f21c60)
    java.lang.Thread@318656032 (0x12fe4e20)
    processing.opengl.PGraphics3D@343302144 (0x14766000)
    processing.core.PApplet$SketchSurfaceViewGL@316919808 (0x12e3d000)
    processing.core.PApplet$InternalEventQueue@345443392 (0x14970c40)
    mypkg.MyTroublesomeProcessingFragment$CurrentTrace@314993488 (0x12c66b50)
    processing.opengl.PGLES@314815264 (0x12c3b320)
    processing.opengl.PShader@315869120 (0x12d3c7c0)
    processing.opengl.PShader@315868880 (0x12d3c6d0)
    processing.opengl.PShader@315867920 (0x12d3c310)
    processing.core.PImage@314746992 (0x12c2a870)
    java.lang.Object[12]@346065984 (0x14a08c40)

mypkg.MyTroublesomeProcessingFragment extends PApplet.

It looks like the PImage is still in memory and through the object tree the reference is retained.

@codeanticode
Copy link
Contributor

All fragments should be automatically disposed when the activity that created them is destroyed, and this won't happen if the app was only paused or stopped. I made some minor changes (668bb06) to make sure that not references to the main activity are left inside the renderer, this might help.

@codeanticode
Copy link
Contributor

codeanticode commented Jul 17, 2016

Also, this thread mentions the use of Activity.finish() and Activity.finishAffinity(), which sounds like the right way to terminate the app and all associated components. I'm going to use finishAffinity() in exit2(), and see what happens.

@codeanticode
Copy link
Contributor

@jsalerno Bugfix release 3.0.1 is available in the CM, do you still see this problem?

@codeanticode
Copy link
Contributor

I replaced the System.exit() call with activity.finish() in 8eaccf1, and didn't see any memory issues so far. Closing this issue, feel free to reopen it if you still find memory leakage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants