Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6863857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:50:19+00:00 2026-05-27T02:50:19+00:00

I have the script that works with pixels in html5 canvas element. And there

  • 0

I have the script that works with pixels in html5 canvas element. And there is some strange behavior by Google Chrome (version: 17.0.942.0 dev). I have 2 kind of operations with pixels:

  • changing the hue of pixels inside particular polygone
  • pixel selection by wand tool

The problem is when I’m changing the hue, the memory of that tab grows after every change up to 250MB (sometimes even more) and than being reseted to the initial size. But when I’m using wand tool selection, the memory doesn’t grow, it goes up or down depending how many pixels are selected (this is normal behavior in my opinion). Please help me to understand why memory grows after every change in first case.

P.S. in FF there is no issue like that, that’s why I think that this is Chrome-specific “strange” behavior

Here is the code of hue change:

function isPointInPoly(poly, pt){
    for(var c = false, i = -1, l = poly.length, j = l - 1; ++i < l; j = i)
        ((poly[i].y <= pt.y && pt.y < poly[j].y) || (poly[j].y <= pt.y && pt.y < poly[i].y))
        && (pt.x < (poly[j].x - poly[i].x) * (pt.y - poly[i].y) / (poly[j].y - poly[i].y) + poly[i].x)
        && (c = !c);
    return c;
}

function changeHue(hue){
    var modifyCanvas = $("#canvas-modify").get(0);
    var modifyContext = modifyCanvas.getContext('2d');
    modifyContext.clearRect(0, 0, modifyCanvas.width, modifyCanvas.height);
    var imageData = $$.mainCanvasContext.getImageData(0, 0, $$.mainCanvasElem.width, $$.mainCanvasElem.height);
    for(var i=0;i<imageData.data.length;i+=4) {
        var p = {x: (i/4)%imageData.width, y: parseInt((i/4)/imageData.width)};
        for(var j=0;j<$$.globalSelection.length;j++){
            var poly = $$.globalSelection[j].slice(0, $$.globalSelection[j].length-1);
            if(isPointInPoly(poly, p)) {
                var hsl = rgbToHsl(imageData.data[i], imageData.data[i+1], imageData.data[i+2]);
                hsl[0] = hue;
                var rgb = hslToRgb(hsl[0], hsl[1], hsl[2]);
                imageData.data[i]   = rgb[0];
                imageData.data[i+1] = rgb[1];
                imageData.data[i+2] = rgb[2];
            } else {
                imageData.data[i]   = 0;
                imageData.data[i+1] = 0;
                imageData.data[i+2] = 0;
                imageData.data[i+3] = 0;
            }
        }
    }
    modifyContext.putImageData(imageData, 0, 0);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:50:20+00:00Added an answer on May 27, 2026 at 2:50 am

    It’s not just you.

    There have been off and on memory leaks in Chrome with anything canvas imageData related.

    For instance:

    http://code.google.com/p/chromium/issues/detail?id=51171

    http://code.google.com/p/chromium/issues/detail?id=20067

    etc.

    Chromium’s issue tracker policies are weird. The issues aren’t necessarily fixed even though they close them.

    It’s possible its a webkit thing and not a Chrome thing but I can’t say for certain. All I can say is that you yourself aren’t doing anything wrong.

    Though while we’re here let me say that you should not be doing this:

    var modifyCanvas = $("#canvas-modify").get(0);
    var modifyContext = modifyCanvas.getContext('2d');
    

    Every time, for performance’s sake. Especially if this operation happens often.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following script that works well in Firefox and Chrome (not sure
I have a JS script that works on IE8 compatibility mode, FF, Chrome, Opera,
I have a script that works in Firefox, Safari, and Chrome. It just doesn't
I have a script that works fine on my test server (using IIS6). The
With help from you guys I now have a script that works like a
I have a java script code that works fine when run through a browser,
I have this RewriteRule that works too well :-) RewriteRule ^([^/]*)/$ /script.html?id=$1 [L] The
I have the following code that works fine in IE: <HTML> <BODY> <script language=JavaScript>
I have this script that works with iconv to automatically convert the encoding of
I have a script that works on different clients, and need to SCP files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.