SQLite Forum

How to free max heap size on execution of sqlite query using sqlite3_exec?
Login
This thread has probably run its course, but in the interest of trying to be helpful:

>Just I want to know why heap size increase on query execution?

Well, so do we. We have no idea. What we do know is:

- 1. It is not SQLite, all of us use it daily and it does no memory leaking.
- 2. That leaves your application, which we do not know and cannot guess at (and mostly we are not C++ programmers).
- 3. Typically memory leaks of the sort is caused by the calling thread (your program) preparing statements, iterating them, but then not finalizing them. or
- 4. receiving strings (in memory allocated by SQLite) from the SQLite APIs (such as Error messages) which you then do not free the memory of. Any memory structure passed to you from an SQLite API which is now no longer under the control of SQLite (and won't be passed back to SQLite to finalize) must be freed by your code.
- 5. Error handling in code sometimes short-circuits the code execution and ends up by-passing the finalization of statements or other memory objects.

That's best we can do, somewhat educated guesses.  Personally I am starting to think you would probably get better feedback from a C++ forum. Try to make the smallest C++ program that shows the leaky behaviour and ask them what is wrong with it (is what I would do).

>If any body technically explain it will be better. Is there method to free it?

As Larry mentioned, this was already handled in another post (#11). We can do no better job than the documentation it shows, but if you do find something in the documentation that is not clear, feel free to quote it here, say what you understand it to mean, and we will gladly help correct any misunderstandings or add clarity.