Freetds Memory leakage

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.