phonegap/phonegap-blackberry-webworks — pull request #55 by filmaj (2011-10-20 21:43:27+00:00)
Title: Fixed memory leak in PhoneGap apps

First, I noticed an issue with a client application on BlackBerry. When I would load the app, close it, and then load it again, a dialog would come up saying "previous instance still active, memory leak reported" or something along those lines.

Googling some returned this thread:

http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/Device-memory-is-Low-issue-for-an-WebWork-app/m-p/1217127/message-uid/1217127/highlight/true#U1217127

In this thread @tneil goes into details about how in certain cases WebWorks will not release the application. @tneil also describes a way to try to prevent this from occurring, by using weak references when keeping references to the `BrowserField` object. He also updates everyone on the thread about how the next WebWorks update should include fixes that alleviate this problem.

In order to bring this solution back into PhoneGap, we need to do two things:

1. Merge in this pull request :) it contains the code changes originally suggested by @tneil, basically wrapping any references to the `BrowserField` object inside a `WeakReference` container object.
2. You have to make sure you update the WebWorks SDK you are running to at least version 2.2.

I also would like to start discussion regarding documenting this issue. Is this something we should potentially add to the README? Please chime in if you have an opinion on this.

Other than that, I think the only thing left is to give props to @tneil. That guy's a monster!