SQLite Forum

How to free max heap size on execution of sqlite query using sqlite3_exec?
> I hope you get understand the example

I understand from the example that you probably
have an [SQL Injection Vulnerability][1]
that is way more important to fix than your alleged memory leak.

[1]: https://en.wikipedia.org/wiki/SQL_injection

I think you need to fix your SQL injections first.  These will be the
most important class of bugs in your application.  Once you have cleaned
up your injections, then and only then should you start looking into
memory usage concerns.