I have this issue with some legacy code (c++). Initially the whole code was designed to be utilized as a stand alone tool. That being said there is an entire network of implicit object destructors that free up memory when code executes. Now the legacy code has a slightly different utility, it is being called repeatedly and objects are not being destructed. Rewriting the whole thing would be a challenge (especially because the original author is not with us any more, code has not comments (i guess people before did not comment a lot - it was obvious ) and noone really is interested in redoing it) is there a way to extract a function call into a separate process with a separate pid which when executes, completely dies calling all implicit destructors for all objects in the process? Any examples ?
I mean, you could certainly spawn an extra process and communicate with it by stdin/stdout. That would make the OS reclaim memory on exit, although it would not do so by running destructors.
That sounds like a good reason to rewrite it…
Having nobody who understands how it works or how to fix it, seems like a pretty terrible situation to me.
I know this problem. Big C++ program, in my case a compiler for the SPIN language for the Parallax Inc Propeller micro-controllers, compiled to asm.js and run in the browser. Worked fine except for leaking 100s of megabytes on every run thanks to the author not cleaning up properly. Luckily the author was a very nice guy and he fixed for us.
It does sound like it's time to bite the bullet and rewrite that thing. It's asking for trouble in the future.