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

  • Home
  • SEARCH
  • 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 9178841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:38:57+00:00 2026-06-17T17:38:57+00:00

If I create a canvas element via: var canvas = document.createElement(‘canvas’); And then draw

  • 0

If I create a canvas element via:

var canvas = document.createElement('canvas');

And then draw to it. If I then keep a reference to that canvas will that use more memory than converting the canvas content to a data url and creating an image element with that data and releasing the reference to the canvas?

Which is less memory consuming? A canvas element or an image element, both the same dimensions with the same image data?

  • 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-06-17T17:38:58+00:00Added an answer on June 17, 2026 at 5:38 pm

    Using this html test page:

    <html>
        <head>
            <script type="text/javascript">
                window.onload = function () {
                    var c = document.getElementById("canvas");
                    var ctx = c.getContext("2d");
                    var img = new Image;
                    img.src = "http://blog.buzzbuzzhome.com/wp-content/uploads/2012/06/Canadian-Flag-canada-729711_1280_1024.jpg";
                    ctx.drawImage(img, 0, 0);
                }
            </script>
        </head>
        <body>
            <canvas id="canvas" width="1280" height="1024"></canvas>
            <img src="http://blog.buzzbuzzhome.com/wp-content/uploads/2012/06/Canadian-Flag-canada-729711_1280_1024.jpg">
        </body>
    </html>
    

    The memory output from a Google Chrome profile snapshot is as follows:

    Google Chrome -> Developer Tools -> Profiles -> Take Head Snapshot -> Class Filter:HTML

    Google Chrome -> Developer Tools -> Profiles -> Take Head Snapshot -> Class Filter:HTML

    The canvas has a smaller retained size (132 to 152 of the img), but a look into what’s left over from rendering the image reveals more:

    Class Filter:canvas

    Class Filter:canvas

    IMHO you’re going to pay an overhead for rendering to the canvas in most major browsers.

    Whether the mess gets cleaned up when your reference is released and your final memory usage is lower is anyone’s guess.

    I realize I didn’t do it strictly the way you intended, but I felt a side by side comparison would give you some idea what’s involved.

    I suppose if loading the image via canvas is the only way to go, perhaps you’re performing some manipulation before outputting the final result, then leaving it in the canvas and attempting to nullify all references for garbage collection will be slightly less expensive for the client.

    This test was only done in Google Chrome and I cannot verify anything for other browsers.

    Try it yourself!

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

Sidebar

Related Questions

So right now I have a simple canvas element with functions that create random
I'm attempting to create an html element as a jQuery object, and then reference
I am trying to create a canvas element that takes up 100% of the
I've a canvas element and I create fabric object out of that. Now, I
I've implemented a canvas element that uses drawarc to create the effect of bubbles
When we create an HTML5 canvas element, a ghost margin appears below the canvas
When I create a dynamic image on a canvas, and then try ti find
I have a static image (a png) that I'm drawing on a canvas element
I am attempting to use an html canvas element to draw each character available
I have a function that rotates an object using the canvas element. When I

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.