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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:03:34+00:00 2026-05-24T04:03:34+00:00

What is a memory efficient way to link two objects? If you store objects

  • 0

What is a memory efficient way to link two objects? If you store objects using two arrays with corresponding index values the object won’t be released from memory.

The implementation should look like the following.

var obj ={};
var linkedobj = getLinkedObject(obj);
var obj2 ={}
var linkedobj2 = getLinkedObject(obj2);            
  • 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-24T04:03:35+00:00Added an answer on May 24, 2026 at 4:03 am

    Objects are general containers

    If all you want to do is associate one object with another one, then why not have them point to one another?

    var obj = {};
    var obj2 = {};
    
    obj.linkedObject = obj2;
    obj2.linkedObject = obj;
    

    This would a normal thing to do, and doesn’t have bad implications on memory.

    Releasing memory

    If you are asking about holding a table full of object references, you are correct that the object will not disappear until all of the live references to it are gone. Javascript has a garbage collector, and as long as your table or array has a good reference, it will be backed by memory for you. If you give an object to a table and then want it to be deleted from memory entirely, you can simply remove it from your table also. You could also just remove the table, assuming it doesn’t need to hold anything else.

    If you are determined to have a getLinkedObject function return an object for another object, you can still allow the objects to each hold the associate reference.

    function getLinkedObject(anObject) {
        return anObject.linkedObject;
    }
    

    This would probably be accompanied by a counterpart:

    function linkObjects(anObject, anotherObject) {
        anObject.linkedObject = anotherObject;
        anotherObject.linkedObject = anObject;
    }
    

    Doing this allows you to worry a little less about memory management, which in Javascript (a high-level, dynamic environment with a garbage collector) is typically appropriate.

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

Sidebar

Related Questions

What is the most memory efficient way to loop through an NSMutableArray of custom
What is the most memory efficient way to remove duplicate lines in a large
I'm looking for a simple, clean and memory-efficient way to create and apply a
Simply what the topic states, what's a memory efficient way to compute a sha256
What's the most efficient way to iterate through an entire table using Datamapper? If
A beginners question about how to be memory efficient when using an UIView which
Possible Duplicate: Most memory efficient way to split an NSString in to substrings I'm
I want a memory-efficient and time-efficient way of splitting up an incoming stream of
Is there a way for a memory efficient ID generation of an URL? At
In C# which is more memory efficient: Option #1 or Option #2? public void

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.