I tried several approaches to make a one-page application using Phonegap, and I'm looking for some general troubleshooting tips.
First approach: This is basically a bunch of different pages and subpages loaded by jquery into containers that live on the index page. Thus, no page is loaded, just loading fragments of the page from the pages into the shell using .load ().
Second approach: I created a one-page html page with all the content, and then displayed and hid it based on the correspondence of the class of the navigation element to the identifier of the content container.
Both approaches work mechanically. The problem is that all my subpages have a gallery or 2-6 images (so I have a total of more than 215 images in total, 660 x 440), for which I used the jquery and Touchwipe loop to activate scrolling with gestures . Galleries work fine, but after scrolling through about 35 galleries, the application always gets a warning level of memory 1, then 2, then a crash. My memory usage in tools looks fine ... the version of the downloaded ajax fragment is stored in bytes with a capacity of 2 megabytes, a single-pager remains stable at about 5 megabytes. Galleries consist of CSS background images in a div, as it seemed to be better than tags.
I see no memory leaks or really no other problems besides memory warnings. I'm kinda stuck on how to track this. I tried trial and error to death. Reduced javascript to simple things. Something seems to grow over time.
Any ideas on how to figure out what is going on? Are there any first approaches to make sure that nothing happens with javascript that causes a memory leak of a certain type?
It is very frustrating that all this works very well, with the exception of the iPad.
My next tactic might be trying to copy gallery background images to empty gifs when not in use.
Here is the code that I use for one pager:
$(document).ready(function(){ document.addEventListener('touchmove', function(e){ e.preventDefault(); }); $('div#mainpages > div').hide(); $("ul#mainnav li").click(function() { $("#mainpages > div").hide(); var navClass = $(this).attr('class'); var target='#'+navClass; $(target).show(); $('[id^=subpages] > div').hide(); $(target).find('[id^=subpages_] div:first').show(); }); $('[id^=subnav] li').click(function() { $('[id^=subnav_] li').removeClass('current'); $('[id^=subpages_] > div').hide(); var subnavClass = $(this).attr('class'); var subtargeted='#'+subnavClass; $(subtargeted).show(); $(this).addClass('current'); $(subtargeted+' .gallery_div_shell').cycle({ timeout: 0, speed: 700, speedIn: 300, speedOut: 300, fx: 'scrollHorz' }); $(subtargeted+' .gallery_div_shell').touchwipe({ wipeLeft: function() { $('.gallery_div_shell').cycle("next"); }, wipeRight: function() { $('.gallery_div_shell').cycle("prev"); } }); }); });
Thanks for any advice, I am pulling my hair out.