lblinc
asked on
MySQL question - memory leaks. how to resolve?
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(MySqlCon nection 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.
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(MySqlCon
{
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.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
ASKER
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..
https://www.experts-exchange.com/questions/21403670/Using-the-dispose-function.html?query=dispose&topics=327