Realloc and Linux

This is a discussion on Realloc and Linux within the Linux Programming forums, part of the Platform Specific Boards category; The program was not failing on the first realloc. It was tying up memory as the program repeated itself and ...

  1. #16
    Registered User
    Join Date
    Jun 2008
    Posts
    93
    The program was not failing on the first realloc. It was tying up memory as the program repeated itself and eventually exhausting all memory. This is when it was crashing.

  2. #17
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,659
    Valgrind has to hold onto the memory so that it (and you) can spot any "use-after-free" memory problems you may have.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #18
    Registered User
    Join Date
    Jun 2008
    Posts
    93
    Aside from Valgrind I am still leaking memory due to constant reallocation. I guess this is just not a valid approach for a large amount of memory reallocation. I think my strategy will be to just malloc a very large cache of 256k blocks at the start of the daemon and then link them together as needed for files rather than realloc the individual blocks. I would imagine this would solve the problem.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. realloc fails
    By beginner.c in forum C Programming
    Replies: 12
    Last Post: 04-27-2007, 08:42 AM
  2. Fast memory copy and realloc()
    By intmail in forum Linux Programming
    Replies: 3
    Last Post: 10-27-2006, 03:46 PM
  3. Realloc problem
    By franziss in forum C Programming
    Replies: 14
    Last Post: 01-25-2005, 09:21 AM
  4. confused about arrays
    By sal817 in forum C Programming
    Replies: 17
    Last Post: 09-20-2004, 03:45 PM
  5. Can't Realloc!
    By robblin in forum C Programming
    Replies: 10
    Last Post: 11-30-2001, 06:17 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21