Re: [GENERAL] memory leak of PQmakeEmptyPGresult?

2004-10-18 Thread Ann


hi,Gaetano Mendola:
 
   you wrote:
 
>  Ann wrote:>  I found the reason of this question and fixed the bug :))> 
> Why then don't you share it ?
 
   em ,because i make a stupid mistake in programming!! :(( 
   I made use of transactions to ensure database consistency, and then, i called PQexec() to begin,commit or rollback a transaction, but ignored clearing the PGresult pointer that was returned by PQexec()...  
 
  I was afraid of others dissipating their energies in it,so, i declared i fixed the bug.
 
  Thank you to pay attention to my question.Thanks very much!!
 
 
 
  Regards   Ann


Do You Yahoo!?150万曲MP3疯狂搜,带您闯入音乐殿堂美女明星应有尽有,搜遍美图、艳图和酷图1G就是1000兆,雅虎电邮自助扩容!Do You Yahoo!?
150万曲MP3疯狂搜,带您闯入音乐殿堂美女明星应有尽有,搜遍美图、艳图和酷图
1G就是1000兆,雅虎电邮自助扩容!

Re: [GENERAL] memory leak of PQmakeEmptyPGresult??

2004-10-13 Thread Gaetano Mendola
Ann wrote:
> I found the reason of this question and fixed the bug :))
> 

Why then don't you share it ?



Regards
Gaetano Mendola


---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


Re: [GENERAL] memory leak of PQmakeEmptyPGresult??

2004-10-12 Thread Ann
I found the reason of this question and fixed the bug :))xiaoling he <[EMAIL PROTECTED]> wrote:

I try to detect potential memory management bugs of my program with valgrind. (PostgreSQL is at version 8.0 beta2. Operating System is Red Hat Enterprise Linux 3. Valgrind is at version 2.2.0.)
 
  After Program terminated, Valgrind reports a memory lost error information as follows:==13524== 208 bytes in 2 blocks are definitely lost in loss record 4 of 12==13524==    at 0x1B903D1C: malloc (vg_replace_malloc.c:131)==13524==    by 0x1B95C8B2: PQmakeEmptyPGresult (in /usr/lib/libpq.so.3.0)==13524==    by 0x1B95D14A: (within /usr/lib/libpq.so.3.0)==13524==    by 0x1B95D963: PQgetResult (in /usr/lib/libpq.so.3.0)      I never call PQmakeEmptyPGresult and PQgetResult function in my program!
 
   Then i searched information about PQmakeEmptyPGresult:  “PQmakeEmptyPGresult Constructs an empty PGresult object with the given status.it is libpq’s internal routine to allocate and initialize an empty PGresult object. It is exported because some applications find it useful to generate result objects (particularly objects with error status)themselves. If conn is not NULL and status indicates an error, the connection’s current error message is copied into the PGresult. Note that PQclear should eventually be called on the object, just as with a PGresult returned by libpq itself. ”
 
  It seems some connection errors happened at the time I do some query or update operations on database.
 
 Now I was puzzled, because program runs normally and returns correct result every time. And I am sure I called PQclear() after everytime called PQexec().
 
  There is a example of my program:Bool bTest(void){  PGresult *res;  char acQryBuf[200]; sprintf(acQryBuf, "%s", "select count(*) from testable "); res =PQexec(conn,acQryBuf);   if ( PQresultStatus(res)!= PGRES_COMMAND_OK){     printf("\n %s\n",PQresultErrorMessage(res));   PQclear(res);  return false;     } PQclear(res); return true;}
 
If PQclear() don't clear PGresult successfully, there will be some memory leaks.Is it right? Why PQclear ()  run unsuccessfully evrytime?
 
Would that have anything to do with it?  Any other ideas of things to try?Thanks! Ann2004.10.12 pm 17:00


Do You Yahoo!?150万曲MP3疯狂搜,带您闯入音乐殿堂美女明星应有尽有,搜遍美图、艳图和酷图1G就是1000兆,雅虎电邮自助扩容!Do You Yahoo!?
150万曲MP3疯狂搜,带您闯入音乐殿堂美女明星应有尽有,搜遍美图、艳图和酷图
1G就是1000兆,雅虎电邮自助扩容!

[GENERAL] memory leak of PQmakeEmptyPGresult??

2004-10-12 Thread xiaoling he
I try to detect potential memory management bugs of my program with valgrind. (PostgreSQL is at version 8.0 beta2. Operating System is Red Hat Enterprise Linux 3. Valgrind is at version 2.2.0.)
 
  After Program terminated, Valgrind reports a memory lost error information as follows:==13524== 208 bytes in 2 blocks are definitely lost in loss record 4 of 12==13524==    at 0x1B903D1C: malloc (vg_replace_malloc.c:131)==13524==    by 0x1B95C8B2: PQmakeEmptyPGresult (in /usr/lib/libpq.so.3.0)==13524==    by 0x1B95D14A: (within /usr/lib/libpq.so.3.0)==13524==    by 0x1B95D963: PQgetResult (in /usr/lib/libpq.so.3.0)      I never call PQmakeEmptyPGresult and PQgetResult function in my program!
 
   Then i searched information about PQmakeEmptyPGresult:  “PQmakeEmptyPGresult Constructs an empty PGresult object with the given status.it is libpq’s internal routine to allocate and initialize an empty PGresult object. It is exported because some applications find it useful to generate result objects (particularly objects with error status)themselves. If conn is not NULL and status indicates an error, the connection’s current error message is copied into the PGresult. Note that PQclear should eventually be called on the object, just as with a PGresult returned by libpq itself. ”
 
  It seems some connection errors happened at the time I do some query or update operations on database.
 
 Now I was puzzled, because program runs normally and returns correct result every time. And I am sure I called PQclear() after everytime called PQexec().
 
  There is a example of my program:Bool bTest(void){  PGresult *res;  char acQryBuf[200]; sprintf(acQryBuf, "%s", "select count(*) from testable "); res =PQexec(conn,acQryBuf);   if ( PQresultStatus(res)!= PGRES_COMMAND_OK){     printf("\n %s\n",PQresultErrorMessage(res));   PQclear(res);  return false;     } PQclear(res); return true;}
 
If PQclear() don't clear PGresult successfully, there will be some memory leaks.Is it right? Why PQclear ()  run unsuccessfully evrytime?
 
Would that have anything to do with it?  Any other ideas of things to try?Thanks! Ann2004.10.12 pm 17:00Do You Yahoo!?
150万曲MP3疯狂搜,带您闯入音乐殿堂美女明星应有尽有,搜遍美图、艳图和酷图
1G就是1000兆,雅虎电邮自助扩容!