Pages: [1]   Go Down
Author Topic: Dynamic memory debugging  (Read 159 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Last week, I was debugging some (seemingly) dynamic memory related problems (e.g., malloc, realloc and free). For this, I wrote some code to log all memory (de)allocations to Serial, and a script to analyze the results. In case it is useful for someone else as well, I've published the code on my blog:

http://www.stderr.nl/Blog/Hardware/Electronics/Arduino/MemoryDebug.html
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12483
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

think it is useful for the tech savvy.

What you could do is to also check the value of (p-2) as there the length of the allocated block is stored IIRC.
p = malloc(n) ==>  [ length] [address where p points to] [... additional bytes]

Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Pages: [1]   Go Up
Jump to: