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 8375655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:13:55+00:00 2026-06-09T15:13:55+00:00

I want to have a bunch of objects, let’s say: function Block() { this.canvas;

  • 0

I want to have a bunch of objects, let’s say:

function Block() {
  this.canvas;
}

blocks = [];

And I will at occasions specify:

block[x] = new Block();

and then:

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

But I will also want to delete this new canvas to free up memory sometimes. Do I just need to do:

block.canvas = null; (or whatever the appropriate method is)

And then javascript will free up the memory at some stage? Or is there an explicit way to delete the object and free up the memory?

Thanks!

  • 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-09T15:13:57+00:00Added an answer on June 9, 2026 at 3:13 pm

    Memory, that is taken by objects, that are referenced nowhere, is recovered in JavaScript by the garbage collection (MDN docu on this).

    So in order to free up the memory, you just have to delete all references to your canvas objects and in the next run of the garbage collector, the memory will be freed again.

    This can be done, like you did, using block.canvas = null; or (depending on the objects/properties scope) by delete block.canvas.

    But be sure, that you remove every reference. This can also be references by the DOM or any other object!

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

Sidebar

Related Questions

In C++, say you have a whole bunch of objects that you want to
I have a bunch of different objects(and objec types) that i want to write
Let's get to the point. This is what I want to do: I have
Let's say I have a list of User objects with two properties...ID and Name
So I have a bunch of objects (thumbnails) and I want every photo to
I have a bunch of datetime objects and I want to calculate the number
I have a bunch of records I want to move to another database and
I have a bunch of variables I want to display of which some are
I have a bunch of anchor tags that I want to select. But if
I have a bunch of numbers timestamps that I want to check against a

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.