malloc/free is there a way ....

malloc/free is there a way to see if all match?

I am exposed to this project where malloc is liberally spread all over the place and wonder if memory get freed up in all cases. I would hate to see that, after a month of usage the thing blew up. A very subtle error in this respect would never show up during development where the program is reloaded many times a day, whereas at a customer where a reset may be a yearly event a small error in this respect would show up eventually.

Erik

Parents
  • Wrap them and keep track of the allocation and release, you can start at a simple level with counting, or extend to tracking which don't get released, or if things get multiply released. This kind of thing will require additional foot prints for the allocation, and maintaining lists. Would suggest allowing for gradation of the level of tracking at compile time depending if it's merely accounting for things, or chasing down specific problems.

    The bigger problem with long term use is the fragmentation/fracturing of the memory pool, where there is enough memory, just not contiguous. A list of current allocation might permit you to map that.

Reply
  • Wrap them and keep track of the allocation and release, you can start at a simple level with counting, or extend to tracking which don't get released, or if things get multiply released. This kind of thing will require additional foot prints for the allocation, and maintaining lists. Would suggest allowing for gradation of the level of tracking at compile time depending if it's merely accounting for things, or chasing down specific problems.

    The bigger problem with long term use is the fragmentation/fracturing of the memory pool, where there is enough memory, just not contiguous. A list of current allocation might permit you to map that.

Children
More questions in this forum