Enabling Memory Management in 3.3.4

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Enabling Memory Management in 3.3.4

Alex Roston
I'm having trouble with the library routine
"sqlite3_release_memory." When I try to use it, the
program exits with a segmentation fault.

I asked the compiler to show me a list of the library
routines and "sqlite3_release_memory" was not present.
From this I concluded that the
SQLITE_ENABLE_MEMORY_MANAGMENT macro has not been
compiled into the library.

What do I need to do at compile time to enable the
SQLITE_ENABLE_MEMORY_MANAGMENT macro? I've tried,

"configure
--enable-SQLITE_ENABLE_MEMORY_MANAGMENT=yes" and
other, similar command lines, but I'm still not seeing
the "sqlite3_release_memory."

Thanks in advance for the help.
Reply | Threaded
Open this post in threaded view
|

Re: Enabling Memory Management in 3.3.4

D. Richard Hipp
Alexander Roston <[hidden email]> wrote:

> I'm having trouble with the library routine
> "sqlite3_release_memory." When I try to use it, the
> program exits with a segmentation fault.
>
> I asked the compiler to show me a list of the library
> routines and "sqlite3_release_memory" was not present.
> >From this I concluded that the
> SQLITE_ENABLE_MEMORY_MANAGMENT macro has not been
> compiled into the library.
>
> What do I need to do at compile time to enable the
> SQLITE_ENABLE_MEMORY_MANAGMENT macro? I've tried,
>
> "configure
> --enable-SQLITE_ENABLE_MEMORY_MANAGMENT=yes" and
> other, similar command lines, but I'm still not seeing
> the "sqlite3_release_memory."
>

You'll need to manually construct your makefile - the
configure script will not do this.  You can either edit
the Makefile that configure generates or write your
own using Makefile.linux-gcc as a template.

The SQLITE_ENABLE_MEMORY_MANAGEMENT feature is intended
for use on embedded devices where a manually created
Makefile is normally required anyway.  What exactly
are you trying to do?  Do you have some unreasonable
expectation of what sqlite3_release_memory is going
to accomplish?

--
D. Richard Hipp   <[hidden email]>

Reply | Threaded
Open this post in threaded view
|

Re: Enabling Memory Management in 3.3.4

Kervin L. Pierre
In reply to this post by Alex Roston
Alexander Roston wrote:
  > I asked the compiler to show me a list of the library
> routines and "sqlite3_release_memory" was not present.

shouldn't that give you a link error rather
than a segfault?  Guessing that if your program
linked properly the linker found the function
somewhere.  Maybe it's finding the wrong version?

Best Regards,
Kervin
Reply | Threaded
Open this post in threaded view
|

Re: Enabling Memory Management in 3.3.4

Alex Roston
In reply to this post by D. Richard Hipp
--- [hidden email] wrote:

> You'll need to manually construct your makefile -
> the
> configure script will not do this.  You can either
> edit
> the Makefile that configure generates or write your
> own using Makefile.linux-gcc as a template.
>
> The SQLITE_ENABLE_MEMORY_MANAGEMENT feature is
> intended
> for use on embedded devices where a manually created
> Makefile is normally required anyway.  What exactly
> are you trying to do?  Do you have some unreasonable
> expectation of what sqlite3_release_memory is going
> to accomplish?
>
> --
> D. Richard Hipp   <[hidden email]>
>
Thanks for the quick reply.

I'm writing a fairly simple server program, no threads
(at least at this point) and I've got a small memory
leak - each time the server accepts a request and adds
the information to the database, it grabs 3-500 bytes
of memory and doesn't let it go. I'd like to tell
sqlite3_release_memory to drop the appropriate amount
of memory and thus fix the memory leak.

I've been using sqlite3_free_table, and while that
reduces the memory use, it doesn't completely fix the
problem.

What specifically do I need to add to the Makefile to
enable SQLITE_ENABLE_MEMORY_MANAGEMENT?

Thanks,

Alex
Reply | Threaded
Open this post in threaded view
|

Re: Enabling Memory Management in 3.3.4

D. Richard Hipp
Alexander Roston <[hidden email]> wrote:
> I've got a small memory
> leak - each time the server accepts a request and adds
> the information to the database, it grabs 3-500 bytes
> of memory and doesn't let it go. I'd like to tell
> sqlite3_release_memory to drop the appropriate amount
> of memory and thus fix the memory leak.
>

That is not going to fix your memory leak.  First off,
SQLite is very carefully tested for memory leaks, so any
you find are more likely in your own code.  sqlite3_release_memory
will clearly not help you there.  Secondly, even if the
leak does turn out to be in SQLite, the sqlite3_release_memory
is only going to release memory that SQLite knows about,
not memory that has leaked.

Your best bet is to find and fix the leak, methinks.
Not treat the symptoms.
--
D. Richard Hipp   <[hidden email]>