Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MySQL question - memory leaks.  how to resolve?

Posted on 2006-11-08
4
Medium Priority
?
1,578 Views
Last Modified: 2012-06-27
info..

dev env     =  VS C# .Net 2003
version     =   MySQL 5.0.27-community-nt via named pipe
connector =    MySQL Connector Net 1.0.8
admin       =   MySQL Admin 1.2.5 rc

My C# app has memory leaks.   From the App..  I make function calls to referenced C++ dlls from inside the VS C# .Net env, however I'm confident that the leaks are not because of C++ code in the dlls not releasing memory.  I reset objects to null and make use of garbage collection fairly well..  so..  I think the problem is with MySQL because recently...  after re-installing MySQL to the latest version 5.0.27 I noticed that the pagefile was reduced by 50% at the startup of the app...   which was a nice surprise.    Not sure if I just changed the settings, thus causing the reduction..  but in any case..

After startup, it is my gut feeling that MySQL is causing the pagefile to grow 2 to 4 MB  every few secs.    I would gladly post my database connectivity code if that would help to find a solution, however for the time being, can anyone direct me to links, or documentation that can help me troubleshoot leaks when running MySQL in the .Net environment?  

I make attempts to release the connection where i think it's necessary as follows:

public virtual void releaseConnection(MySqlConnection connection)
{
    try
    {
         connection.Close();
         connection.Dispose();
     }
     catch (Exception ex)
     {
          WriteStackTrace(ex, Console.Error);
     }
}

Note:  In the Task Manager, when machine is at rest.. with no Apps running..      MySQL looks as follows:

Image Name               Mem Usage              VM Size               Handles            Threads
mysqld-nt.exe               15,392 K                  84,9565 K             4,457                15

The mysqld-nt.exe stays relatively the same size, however....  when my VS C# App is then running, the App's exe continues to grow in size, possibly because I'm not using MySQL properly in order for the garbage collection to release memory that MySQL is utilizing.    Any input appreciated here.   More specific info can be provided upon request.    Thanks.
0
Comment
Question by:lblinc
  • 2
4 Comments
 
LVL 12

Assisted Solution

by:AdrianSRU
AdrianSRU earned 400 total points
ID: 17900025
Can you post a section of code where you are executing a query?  That's my guess for where the problem is.  You can test that by putting a simple query in a loop to execute a few thousand times and see if that increases the memory usage.


--Adrian
0
 
LVL 35

Accepted Solution

by:
Raynard7 earned 1600 total points
ID: 17902238
Hi,

A few pointers firstly I am assuming when you installed the new version of mysql you reverted back to the default configuation - this is not particularly fast.  You would be best tuning it for what you are doing - ie the table types, how much ram is associated - what processors you are using

http://dev.mysql.com/books/hpmysql-excerpts/ch06.html
dev.mysql.com/doc/refman/5.0/en/optimization.html

the other thing is that you mention that you are disposing of the connection - but if you have connection pooling the connection is not closed at all - and will not release resources

if you add
Pooling=False;
to your connection string - it will disable connection pooling - meaning that when you close the connection it is actually closed
0
 

Author Comment

by:lblinc
ID: 17907516
these are helpful in my troubleshooting efforts, thanks.    i will need a bit more time researching things and trying to narrow it down as to where leaks are at..       please allow me a day or two for debugging and tweaking the mysql settings to get back with more info.    i truly appreciate the advice.    

you know, i did notice one thing in particular in another post that may be relevant in my case, as follows:      gregoryyoung mentioned the possibility of an exception making a close not occur, and I need to look into this possibilty of this occurance in my try{} catch{}  finally{}  code blocks.

i think it was from this other post..

http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_21403670.html?query=dispose&topics=327

0
 
LVL 35

Expert Comment

by:Raynard7
ID: 17912132
you could always test this by having a finally after any try catches you have - checking if the connection is open - and if it is then throwing another error
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question