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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:51:28+00:00 2026-05-19T16:51:28+00:00

Could someone please help me understand the concept of memory leaking and how specific

  • 0

Could someone please help me understand the concept of memory leaking and how specific data structures promote/prevent it (e.g. linked lists, arrays etc). I’ve been taught it twice by 2 different people a while ago – which has confused me slightly because of the differences in teaching methods.

  • 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-19T16:51:29+00:00Added an answer on May 19, 2026 at 4:51 pm

    Wikipedia has a good description on memory leaks. The defintion given there is:

    A memory leak, in computer science (or leakage, in this context), occurs 
    when a computer program consumes memory but is unable to release it back 
    to the operating system.
    

    For example, the following C function leaks memory:

    void leaky(int n)
    {
        char* a = malloc(n);
        char* b = malloc(n);
        // Do something with a
        // Do something with b
        free(a);
    }
    

    The above function leaks n bytes of memory as the programmer forgot to call free(b). What that means is that the operating system has n bytes less memory to satisfy further calls to malloc. If the program calls leaky many times, the OS may eventually run out of memory that it could allocate for other tasks.

    As for the second part of your question, there is nothing intrinsic to data structures that makes them leak memory, but a careless implementation of a data structure could leak memory. As an example, consider the following function that deletes an element from a linked list:

    // I guess you could figure out where memory is leaking and fix it.
    
    void delete_element(ListNode* node, int key)
    {
        if (node != NULL)
        {
            if (node->key == key)
            {
                if (node->prev != NULL) {
                    // Unlink the node from the list.
                    node->prev->next = node->next;
                }
            }
            else
            {
                delete_element(node->next, key);
            }  
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please could someone help me understand why the div.fl element shown in Developer Tools
I'm quite new to Spring Framework. Could someone please help me understand the spring
Could someone please help me to understand why the following block of code keeps
Could someone here please help me understand how to determine when floating point limitations
Could someone please help me understand what the link tags are used for within
SQL Server Mgmt Studio 2005: could someone please help me understand how to view
Could someone please help me to understand what Unity is and how it's simplifying
Could someone please help me to understand what the 'send()' method listed below is
Could someone please help me understand that why am I getting this error at
Could someone please help me to understand how to get all parameters passed to

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.