Well it appears that I spoke too hastily. Using mysql_close() with seperate
free'ing seemed to fix my problem on the HP but not on intel Linux where I get
segmentation faults after re-initializing the previously free'd MYSQL*. I don't
know if I'm just getting lucky on the HPUx or if there's platform specific code in
the client library code or who knows what! I'm presently working on a smaller piece
of sample code that demonstrates the problem (and possible disparity between
platforms) more clearly.
Meanwhile, can someone at the MySQL group give some policy information on
reclaiming then reallocating MYSQL instances? Is free() supposed to be used or is
mysql_close() supposed to do everything for me (which it isn't)? The goal is to be
able to establish multiple connections to various database servers, close them,
reclaim their memory, reinitialize them, and so on and so forth...
Please help cause this is getting most confusing!
Ben Scherrey
Benjamin Scherrey wrote:
> Seperately free'ing the MYSQL structure, as you suggested, does indeed
> eliminate the memory leak. Unfortunately the manual never mentions the use of
> free for a structure the library allocates. In fact, in the documentation of
> mysql_init(), mysql_close() is described as the mechanism to free up this
> memory. Only thing worse than no documentation is wrong documentation! :-(