Go Down

Topic: Memory Management (Read 1 time) previous topic - next topic


Can I use alloc() to load a whole class into memory? (I guess I mean a whole object based on a class), and then use free() afterwards?

I've written a project based on a dozen or more library's I've written. I've estimated the memory footprint of some of the larger objects to be about 500 bytes (I do quite a bit of string manipulation which seems to take up a lot of space). Several of those objects are used once and once only during the 'setup()' part of the sketch. My (limited) understanding is that this memory once allocated stays there permanently, even if the object doesn't get used again, is this correct?

My application is running (very) low on memory, is there a way of freeing up this memory after the object has done what it's got to do?

Also, is there a tutorial on memory management directed specifically to the arduino? I've tried to read-up on this subject, but a lot of the general C and c++ stuff I read is often different from what I read on this forum.



I don't know your code and some libs automatically create a static instance, so it depends on the lib.

If you split your application in several functions that are to be called sequentially in loop() that may lower the footprint. If you want us to help Please share your code.

Rob Tillaart

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


so far I did not use alloca or malloc for my arduino programs, but this should apply directly to the arduino environment:

alloca() does not require free()
malloc() requires a call to free()



Thanks, that 2nd link was particularly informative.

Most of my librarys are large and require extra hardware, so I'm niot sure ther'd be much to gain by posting the whole thing here.

Thanks guys

Go Up