|
|
Home » U++ Library support » U++ SQL » [BUG] Memory leak in MySql package
|
|
Re: [BUG] Memory leak in MySql package [message #39719 is a reply to message #39714] |
Sat, 20 April 2013 15:05   |
 |
Klugier
Messages: 1099 Registered: September 2012 Location: Poland, Kraków
|
Senior Contributor |
|
|
Hello Alboni,
You are absolutly right, We need to count global number of MySqlSession instances. If the number of instances falls to zero we need to call mysql_library_end().
I use a memory profiler called valgrind. I invoke him with following command:
valgrind --tool=memcheck --leak-check=full --show-reachable=yes ./ProgramName
I enclose completed patch for this issue. I have added new static variable to count number of instances (numberOfInstances) of the class MySqlSession.
Sincerely,
Klugier
U++ - one framework to rule them all.
[Updated on: Sat, 20 April 2013 15:35] Report message to a moderator
|
|
|
|
|
|
|
Re: [BUG] Memory leak in MySql package [message #39981 is a reply to message #39925] |
Wed, 22 May 2013 09:41   |
 |
mirek
Messages: 14255 Registered: November 2005
|
Ultimate Member |
|
|
klugier wrote on Sat, 11 May 2013 11:19 | Hello Mirek,
I sorry, I have sent wrong header file. Of course, we need to add "counter" code to constructor and destructor.
MySqlSession() { numberOfInstances++; mysql = NULL; Dialect(MY_SQL); }
~MySqlSession() { numberOfInstances--; Close(); }
I would like to relate to putting EXITBLOCK. In my option counter method is more efficient, because memory can be free at runtime. On the other hand, EXITBLOCK will make order when the program ends. Of course, I can be wrong what EXITBLOCK is doing. I have never used it in my applications.
|
Well, I think that amount of memory is not high and there is plausible usage scenario where you create DB connection per request - in that case MySql will have to recreate the whole memory area....
Frankly, more I am thinking about this, perhaps the best course of action is to do nothing. This is a 'leak' we can afford.
Mirek
|
|
|
|
|
Re: [BUG] Memory leak in MySql package [message #39985 is a reply to message #39611] |
Wed, 22 May 2013 11:53   |
 |
Alboni
Messages: 216 Registered: January 2012 Location: Kajaani, Finland
|
Experienced Member |
|
|
The point is that the MySql documentation says that mysql_library_end() should be called before closing the program. MySql was written by smart people and I see no reason to doubt their wisdom. I don't know what problems not calling it induces. Maybe none. Maybe some that are not evident. I haven't analysed MySql sourcecode.
[Updated on: Wed, 22 May 2013 12:04] Report message to a moderator
|
|
|
|
|
|
Goto Forum:
Current Time: Fri Apr 25 19:10:55 CEST 2025
Total time taken to generate the page: 0.01460 seconds
|
|
|