www.panelsoft.com

 

 

 

Home

Training

Reading

PanelSoft

User Interfaces and Usability for Embedded Systems


Feedback to "More on Memory Leaks"- Murphy's Law, April 2002

Read the original artilce at More on Memory Leaks

return to Murphy's Law

 

From: Uri Sabadosh To: nmurphy@panelsoft.com Sent: Friday, April 05, 2002 11:45 PM Subject: More on Memory Leaks

Hi,

Why bother? Best method is to allocate all you need on start up. Uri

Uri,

Niall's reply

"All you need" may be more RAM than exists on the board. Your opinion is totally valid and is exactly the right way to go on a SMALL system. Once you have 5k or 10k lines of code then that assumption starts to get you into trouble. It will always be possible to allocate everything upfront, but this always means using more RAM than a heap mechanism which allows memory that was used at one time for a communications buffer to be used later to store sensor readings.

Also libraries are an issue. If I write a routine that can receive a buffer of information that arrives on some comms port. First I do not know how big to make the buffer, since the size of data arriving might be indicated in the data stream. Then the code calling my routine might use that buffer for 1 millisecond, or it might need it for an hour. I do not know because I am only writing the comms library and I do not know who will call me or when. Many buffers may be allocated and then freed later on in a different order, so I do not know how many buffers to create ahead of time or how big to make them. Again, on small systems, you do not have these divisions in the software, but in large systems, you can not write the code without them.

regards,

Niall Murphy

 


 


[PanelSoft Home | Training Courses ]