Article Title: freetds Memory leakage. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
When freetds is used, frequent connections are found. When the database is closed, memory continues to grow. I searched for some articles in China on the Internet, which is the same as the method I used. Finally, I found the reason on the official website, so I wrote it for your reference. The following code is found on the Internet, and the red part needs to be added. This example is executed only once, so the memory leakage problem is hidden.
The author of Freetds said that dbinit and dbexit must be executed once. It is okay to execute them multiple times during the test again.
# Include
# Include
# Include
# Include
# Include
# Include
Int main (void)
{
While (1)
{
Char szUsername [32] = "test ";
Char szPassword [32] = "test ";
Char szDBName [32] = "test ";
Char szServer [32] = "2.2.2.2: 1433 ";
// Initialize db-library
Dbinit ();
// Connect to the database
LOGINREC * loginrec = dblogin ();
DBSETLUSER (loginrec, szUsername );
DBSETLPWD (loginrec, szPassword );
DBPROCESS * dbprocess = dbopen (loginrec, szServer );
If (dbprocess = FAIL ){
Printf ("ASB >> Conect ms SQL SERVER fail \ n ");
Return 0;
} Else {
Printf ("ASB> ConnectEMS conect ms SQL SERVER success \ n ");
}
If (dbuse (dbprocess, szDBName) = FAIL ){
Printf ("ASB> Open database name fail \ n ");
} Else {
Printf ("ASB> Open database name success \ n ");
}
[1] [2] Next page