SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Addict ketting00's Avatar
    Join Date
    Jul 2011
    Posts
    328
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    How to prevent Chrome do garbage collection my application?

    My application has very long lifespan and I want to use static memory to keep it run smoothly.
    Since it's not a game application, I have no idea how to do the object pooling. All I can think of is keeping variables busy by refer them to something.
    How could I do that?
    The codes below gets GC every roughly 50s. I want it to live longer or no GC at all:
    Code:
    var video = document.createElement('video')
      , canvas = document.getElementById('canvas')
      , ctx = canvas.getContext('2d')
      ;
    
    window.addEventListener('load', function() {
    	video.src = 'my_video.ogg';
    	video.play();
    	playVideo(video);
    });
    
    var playVideo = function(video) {
    	this.video = video;
    	(function paintCanvas(video) {
    		window.webkitRequestAnimationFrame(paintCanvas);
    		ctx.drawImage(this.video, 0, 0, canvas.width, canvas.height);
    	})();
    }
    Thank you,
    Last edited by ParkinT; Jul 17, 2013 at 06:55. Reason: Corrected 'CG' to 'GC'

  2. #2
    SitePoint Addict ketting00's Avatar
    Join Date
    Jul 2011
    Posts
    328
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    This function seems to help extended garbage collecting time but it boats memory usage up considerably:

    http://javascript.crockford.com/memory/leak.html


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •