Solved

MySQL question - memory leaks.  how to resolve?

Posted on 2006-11-08
4
1,512 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 12

Assisted Solution

by:AdrianSRU
AdrianSRU earned 100 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 400 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Creating and Managing Databases with phpMyAdmin in cPanel.
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

630 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