blackberry / WebWorks

BlackBerry WebWorks for Smartphones is a platform for building deeply integrated web applications for BlackBerry smartphones
http://developer.blackberry.com/html5
268 stars 51 forks source link

Memory Leak issue #47

Closed tneil closed 12 years ago

tneil commented 13 years ago

Background

There seems to be some kind of memory leak when moving from page to page in a WebWorks application. Some details from the community can be found in the forums.

Memory issues surrounding Java based Scriptable objects were tackled in a previous release. These seem to have a different cause.

tneil commented 13 years ago

One initial discovery is that it looks like Focus Based Navigation could be causing some of the memory issues. This could be related to its handles to the DOM through the synchronous IPC channel to WebKit.

This issue currently is not reproducible on BB5

It also seems to happen when changes are made to the DOM. This could also be one of the reasons that Focus based navigation has a role to play. Each time the DOM is changed the Focus based navigation re-indexes the nodes in the DOM.

tneil commented 12 years ago

Latest findings

It appears as though Focus Based Navigation was one aspect playing into this memory leak. The fact that the Java code had pointers to the DOM in WebKit made it so that WebKit would not clear the memory for the current DOM even after loading in a new page.

The new Focus Based Navigation should address this aspect of the memory leak.

After trying the new Focus Based Navigation Prototype we found that there continued to be a leak where the DOM was not being released by WebKit. This looks to be triggered when a JavaScript extension uses a Callback mechanism where a handle to a JavaScript function is held in the Java runtime.

Initial investigation shows that if a garbage collection is called on the Java runtime it does clean up this memory. Current approach is to try and detect low memory conditions and request a garbage collection.

Results are still to be verified.

tneil commented 12 years ago

This issue has been resolved. Details on the fix can be found here:

http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/PRE-RELEASE-Memory-Leak-Fix-Download/td-p/1335253