Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MySQL question - memory leaks.  how to resolve?

Posted on 2006-11-08
4
Medium Priority
?
1,553 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 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
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…
Suggested Courses

670 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