Skip to content
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

Memory Issue #13

Closed
areinhold17 opened this issue Jul 8, 2013 · 2 comments
Closed

Memory Issue #13

areinhold17 opened this issue Jul 8, 2013 · 2 comments

Comments

@areinhold17
Copy link

I am creating an App using the JS Coverflow (http://luwes.co/labs/js-cover-flow/)[App is created for IOS, with Cordova Phonegap], I have creating the implementation using JS in order to make the inline Json array dynamic. Tha gallery value is pullin from a text file in my project that conatins an array of the required information. Functionality wise everything is working wonderfully. My problem is that when I change the artist a few times, and remake the coverflow for each one, after enough have been loaded the app crashed. I think memory is not being released for the images loaded for the previous artists, even though only the current artist's images are showing (max of 15 at a time). Does anyone have a suggestion on how I can manage this memory?

As far as errors, I receive the 'Received memory warning.' error from the MainViewController, and occasionally 'Max open files: 78'

function playlistType(index,num){
$('#coverflowplaylist').html('');
if(gallery==null||gallery=='')alert('null');
var html='';
html+='<script>';

html+=' function reset() {var replacement = document.createElement('div');replacement.id = "container"; var el = document.getElementById('container');el.parentNode.replaceChild(replacement, el);';
html+=' coverflow('container').setup({ item: 1, width: 1024, height:618,backgroundcolor: '000000',gradientcolor: '000000',';
html+=' playlist:[';
var h=1;
for(var i=0;i<gallery.length;i++){//for(var i=0;i<gallery.length;i++){
if(gallery[i].type==index){

    if(h>((num-1)*15) && h<(num*15)){
        html+='{"image": "../../Documents/'+gallery[i].prettyid+'.jpg", "link":"../../Documents/'+gallery[i].prettyid+'.jpg"}';//Image/Link
        if(i!=gallery.length-1){html+=','};
    }
    h++
}

}
html+='],coverwidth: 600, coverheight: 400,coverdepth:300, coverangle:40, covergap: 100,fixedsize: true,textoffset: 50,x:0,y:0 })';
html+='.on('ready', function() {this.on('focus', function(index) {document.getElementById('focusindex').innerHTML = index;captionReplaceType(''+index+'',''+num+'');});';
html+='this.on('click', function(index, link) {document.getElementById('clickindex').innerHTML = index;console.log(link);});});}reset();</script>';
$('#coverflowplaylist').html(html);
reset();
coverflow().to(3);
}

@luwes
Copy link
Owner

luwes commented Jul 13, 2013

I made a small change improving the remove (destroy) handling.
Make sure you are using the new remove() method before the setup.

coverflow('container').remove();
coverflow('container').setup({

Please let me know if this improves the memory issues you are having.

@areinhold17
Copy link
Author

I have added the new code and the remove function, and It appears to have fixed the issue. Thank you for your help, this is great.

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