Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Highlighted
Regular Contributor
Posts: 51
Registered: ‎07-20-2011
My Device: PlayBook
My Carrier: RIM

Memory leak using focused based navigation - test case included

Hi there, 

 

I've isolated from my application a test case that proves the memory leak in WebWorks 2.2 when using focused based navigation. 

 

I guess that RIM developers would be interested in taking a look into this. Please include jquery when building the example, and also an img (anyone will do).

 

I've tested this using a Bold 9780 running OS 6.0.0.706. The application runs a script that loads a set of images, removes them from the DOM, and back again. Less than a minute after starting, a memory low warning alert will appear, and the application is closed. 

 

As a bonus, if you add an application icon, after the application is closed, your application icon will be replaced by the default icon. 

 

 

Thanks for your interest.

 

config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" 
	 version="1.0.10.857" >
  <name>LP20</name>
  <author>Tests Inc.</author>
  <content src="landing.html"/>

 <rim:navigation mode="focus"/>
 
</widget>

 

landing.html 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
    <head> 
        <title>WWLeak</title>
        <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, user-scalable=no, minimum-scale=1, maximum-scale=1" />
        <script type="text/javascript" src="js/jquery-1.6.4.min.js"></script>
        <script type="text/javascript">
	        function cleanup() {
	        	$('#container').children().remove();
	        }
	
	        function redraw() {
	        	cleanup();
	        	var div = $('<div>'), i;
	        	for (i=0; i<300; i++) {
	        		div.append('<img src="image.png" x-blackberry-focusable="true">');
	        	}
	        	$('#container').append(div);
	        }
	
	
	        $(function() {
	        	setInterval(
	        		function() {
	        			redraw();
	        		},
	        		5000
	        	);
	        });        
        </script>
        
    </head> 
    <body>
    	<div id="container">
    	
    	</div>
	</body>
</html>

 

Others: 

  • jquery-1.6.4.min.js (download from jquery site)
  • image.png (use your favorite png)

 

 

 

 

 

 

Retired
Posts: 518
Registered: ‎07-18-2011
My Device: Bold
My Carrier: Rogers

Re: Memory leak using focused based navigation - test case included

Thanks MLUY,

 

We're definately looking into it



1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the button below the post(s)
Regular Contributor
Posts: 51
Registered: ‎07-20-2011
My Device: PlayBook
My Carrier: RIM

Re: Memory leak using focused based navigation - test case included

Hi, I hope you were able to reproduce this, have you? 

 

I'm pretty much interested in the second part of the problem: the application icon changes after the application crashes. Have you been able to reproduce this also?

Retired
Posts: 518
Registered: ‎07-18-2011
My Device: Bold
My Carrier: Rogers

Re: Memory leak using focused based navigation - test case included

[ Edited ]

Hi MLUY,

 

We were able to reproduce the issue sorry for not posting that earlier. There were some device models where it doesn't happen and some where it does but no matter what the impact was much improved using 2.3 (if not completely fixed).

 

As per the icon, I'll double check with the testing team and post back.



1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the button below the post(s)
Regular Contributor
Posts: 51
Registered: ‎07-20-2011
My Device: PlayBook
My Carrier: RIM

Re: Memory leak using focused based navigation - test case included

Can you share on which devices you were/weren't able to reproduce this? 

 

I was told by devsupport that the issue is still present in 2.3. 

 

Please let me know your findings about the icon changing problem.

 

Thanks

Retired
Posts: 518
Registered: ‎07-18-2011
My Device: Bold
My Carrier: Rogers

Re: Memory leak using focused based navigation - test case included

Hi MLUY,

 

I believe the majority of devices that did not reproduce were recent 7.0 devices.

 

As per the icon, did you mean if you added the icon through the API or had it in the config.xml. We tested with an icon in the config.xml and did not see it change in any way.



1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the button below the post(s)
Contributor
Posts: 13
Registered: ‎02-09-2012
My Device: Blackberry 9700 Bold
My Carrier: Orange

Re: Memory leak using focused based navigation - test case included

Hi, 

 

is any workaround on this problem. In my case error occurs when we display only 25 pics.

 

BR

 

 

Contributor
Posts: 13
Registered: ‎02-09-2012
My Device: Blackberry 9700 Bold
My Carrier: Orange

Re: Memory leak using focused based navigation - test case included

Anybody resolved our issue, if no maybe the only way is give feed back to our sponsor that there is no way to develop apps on bb 6.0 and we should waiting for new os releases ?

 

Is any way to escalate problems from this forum ?

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Memory leak using focused based navigation - test case included

What happens if you add and remove the images using standard JavaScript DOM mainipulation instead of using jQuery.   

 

Have you tried adding the images all through a document fragment and then inserting them in the live DOM vs loading them individually?

 

In your existing code, each append of the <div> will trigger a layout computation and then a re-indexing of the focus based navigation tree which all also use memory.

 

Have you tried disabling focus based navigation?  Does it make any difference?

 

 

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Regular Contributor
Posts: 51
Registered: ‎07-20-2011
My Device: PlayBook
My Carrier: RIM

Re: Memory leak using focused based navigation - test case included

Hi tneil, thanks for the interest. 

 

This issue only happens with focus based navigation. If you disable, the sample application runs like 3 hours without problem (instead of less than one minute). 

 

I don't have time now to try any other of your suggestions. In fact, I removed focus based navigation and really don't plan to re-enable it.

 

The guy from dev support tried the following, neither of them helped:

 

A few changes I tried:
1) Using the HTML5 <!DOCTYPE html> declaration.
2) Newer JQuery version (1.7.1)
3) Instead of removing and appending children, leveraging the html('') method to clear the HTML of the container.
4) When adding multiple <image> elements, storing all items in a String, then making only one call to html(stringOfAllElements).
5) Leveraging recursive calls to setTimeout() instead of the initial call to setInterval().