help-garbage

Hello.
I am using a library which seemingly doesn't reclaim memory automatically, and thus I get memory allocation errors from some point on in my program. I think I should do Garbage collection manually, but don't know how to do that.
Hi!

Try using Object Oriented Programming.

Memory allocation should be done in the constructors.
Memory deallocation should be done in the destructors.

Easy.
there is no garbage collection in C++.
If the library allocates memory then it should mention it someplace, typically the documentation will also tell you if you are supposed to free the memory after use of the library is over or whether it will free the memory used.

In your case it seems the caller is supposed to free the allocated memory.
If you are allocating for using library functions then of course you will have to free the memory.
Topic archived. No new replies allowed.