This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

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
  • 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.

    Unfortunately even complete absence of such mismatches (a.k.a. memory leaks) doesn't really solve the problem. There's that nasty effect called heap fragmentation that will cause allocatio requestes to fail even though the total size of free memory would be sufficient to satisfy them.

    The only sane approach for truly embedded systems that are expected to run indefinitely is to only use malloc() during start-up, and never free() at all --- and make sure that there's enough memory for those malloc()s in every allowed configuration.

Reply
  • 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.

    Unfortunately even complete absence of such mismatches (a.k.a. memory leaks) doesn't really solve the problem. There's that nasty effect called heap fragmentation that will cause allocatio requestes to fail even though the total size of free memory would be sufficient to satisfy them.

    The only sane approach for truly embedded systems that are expected to run indefinitely is to only use malloc() during start-up, and never free() at all --- and make sure that there's enough memory for those malloc()s in every allowed configuration.

Children
No data