Thread: linked list memory

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    88

    linked list memory

    Is there a way to find out how much memory a linked list takes up?

  2. #2
    root
    Join Date
    Sep 2003
    Posts
    232
    Count the number of items in the list, multiply by the size of a single item. That should do it unless you allocate memory inside of each item, then you'd have to save that and read it later.
    The information given in this message is known to work on FreeBSD 4.8 STABLE.
    *The above statement is false if I was too lazy to test it.*
    Please take note that I am not a technical writer, nor do I care to become one.
    If someone finds a mistake, gleaming error or typo, do me a favor...bite me.
    Don't assume that I'm ever entirely serious or entirely joking.

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    88
    how do I find the memory that a single node takes up?

  4. #4
    root
    Join Date
    Sep 2003
    Posts
    232
    sizeof(struct node);

    or

    sizeof(*head);

    or anything equivalent.
    The information given in this message is known to work on FreeBSD 4.8 STABLE.
    *The above statement is false if I was too lazy to test it.*
    Please take note that I am not a technical writer, nor do I care to become one.
    If someone finds a mistake, gleaming error or typo, do me a favor...bite me.
    Don't assume that I'm ever entirely serious or entirely joking.

  5. #5
    Registered User
    Join Date
    Apr 2003
    Posts
    88
    thanks for your help

  6. #6
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by AmazingRando
    how do I find the memory that a single node takes up?
    It's the same value to passed to the malloc() function when you created said node.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with linked list and shared memory
    By Sirfabius in forum C Programming
    Replies: 10
    Last Post: 11-10-2008, 04:45 PM
  2. singly linked circular list
    By DarkDot in forum C++ Programming
    Replies: 0
    Last Post: 04-24-2007, 08:55 PM
  3. Template Class for Linked List
    By pecymanski in forum C++ Programming
    Replies: 2
    Last Post: 12-04-2001, 09:07 PM
  4. 1st Class LIST ADT
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 11-09-2001, 07:29 PM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM