Re: [sqlite] RE:Re: [sqlite] SQLite memory leak on Windows CE

2006-03-15 Thread Jose Da Silva
On March 14, 2006 01:49 pm, [EMAIL PROTECTED]  wrote:
> Hello again,
> Thank for your answers:
> first of all thank you who pointed that i should use a close(db) at
> line 17 and call sqlite3_free_table(result) even if there was an
> error, but these solutions didn´t solve my problem (the execution
> code never reached that point because ret value was always
> SQLITE_OK). Do anyone of you work with SQLite on Windows CE?

No, I don't have win ce either.
However, I looked at the sqlite code and there may be a bug.

In SQLite3.3.4 go to:
"src\table.c" line 192 and change "azResult--;"
changed_from-
190  if( azResult ){
191int i, n;
192azResult--;
193if( azResult==0 ) return;
194n = (int)azResult[0];
changed_to-
190  if( azResult ){
191int i, n;
192azResult -= sizeof(char*);  

Re: [sqlite] RE:Re: [sqlite] SQLite memory leak on Windows CE

2006-03-14 Thread Jay Sprenkle
On 3/14/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hello again,
> Thank for your answers:
> first of all thank you who pointed that i should use a close(db) at line 17 
> and call sqlite3_free_table(result) even if there was an error, but these 
> solutions didn´t solve my problem (the execution code never reached that 
> point because ret value was always SQLITE_OK).
> Do anyone of you work with SQLite on Windows CE?

Sorry, I don't have windows CE available to me to test on.


[sqlite] RE:Re: [sqlite] SQLite memory leak on Windows CE

2006-03-14 Thread [EMAIL PROTECTED]

Hello again,
Thank for your answers:
first of all thank you who pointed that i should use a close(db) at line 17 and 
call sqlite3_free_table(result) even if there was an error, but these solutions 
didn´t solve my problem (the execution code never reached that point because 
ret value was always SQLITE_OK).
Do anyone of you work with SQLite on Windows CE?
if you guys work with it then it might be interesting if you try my code (with 
a quite big table) and examine the memory using the remote performance monitor 
of EVC   4.0 under the tools menu.

Thank you everyone
Eduardo Esteban
---Mensaje original---You might look to recoding your application to not use 
get_table, a 
memory hog.  Instead use step in a loop.

Jay Sprenkle wrote:
> On 3/14/06, [EMAIL PROTECTED]  wrote:
> 
>>Hi all,
>>I am having real problems with SQLite on Windows CE (.NET 4.1 and 
Pocket PC 2003).
> 
> 
>> ret = sqlite3_get_table(db, "SELECT * FROM artic", 
&result, &rows, &cols, &errmsg);
>> if (ret != SQLITE_OK)
>> {
>> MessageBox(_T("Error en SQL"),_T("Error"),MB_OK);
>> sqlite3_free(errmsg);
> 
> 
> You might call sqlite3_free_table(result) here. Without looking at the 
source
> code it might have allocated a result even though there was an error.
> 
> 
> 
>>return;
>> }
>> else {
>> MessageBox(_T("Erroron SQL 
sentence"),_T("Error"),MB_OK);
>> }
>>sqlite3_free_table(result);
>> sqlite3_close(db);
>>}
> 
> 
> 
> Did you look at the source code for sqlite3_get_table()?
> It's easy to get and may be very helpful.



Automóviles, telefonía, imagen y sonido, belleza... ¡encuentra gratis todo lo 
que necesitas! http://clasificados.wanadoo.es/

Re: [sqlite] SQLite memory leak on Windows CE

2006-03-14 Thread Jose Da Silva
On March 14, 2006 12:03 pm, [EMAIL PROTECTED]  wrote:
> Hi all,
> I am having real problems with SQLite on Windows CE (.NET 4.1 and
> Pocket PC 2003). I have tried everything and it seems that there is a
> memory leak with SQLite on Windows CE. I have test it with SQLite
> versions 3.2.2 and 3.3.4 and SQLite seems that it reserves memory and
> doesn´t free it after using it, memery is freed only after the main
> program has finished. Take this simple example (it fails also with
> more complicated ones). I have test it using a quite big table
> (20,000 records).
>
> Please i really need help, because my program consumes all the memory
> and i need to finish it next week: Here is the sample source code to
> test (this is done with EVC   4.0 and a MFC application) void

1>CMemoryMDlg::OnButton1() {
2>  char *errmsg;
3>  char **result;
4>  sqlite3 *db;
5>  int ret, rows, cols;
6>
7>  int n = sqlite3_open("\\mysqlitebd.db", &db);
8>  if (db == 0) {
9>MessageBox(_T("Error openning BD"),_T(""),MB_OK);
10>return;
11>  }
12>  ret = sqlite3_get_table(db, "SELECT * FROM artic",
13>&result, &rows, &cols, &errmsg);
14>  if (ret != SQLITE_OK) {
15>MessageBox(_T("Error en SQL"),_T("Error"),MB_OK);
16>sqlite3_free(errmsg);
17>return;
18>  } else {
19>MessageBox(_T("Error on SQL sentence"),_T("Error"),MB_OK);
20>  }
21>  sqlite3_free_table(result);
22>  sqlite3_close(db);
23>}

Looking at your code, please note that from line 12 onwards you NOW
 have a database open so you have to CLOSE(db). I notice that you only
 close it at line 22 but forgot/failed to do a CLOSE(db) before you
 RETURN on line 17.
I recommend you check your other routines for a common fault in
forgetting to close all open handles and allocated memories before
doing a RETURN if you hit an error.

I did not test your code but note the above just from reading your
 code. Other readers may point out other issues besides the one I
 mentioned.

Hope that helps.


Re: [sqlite] SQLite memory leak on Windows CE

2006-03-14 Thread John Stanton
You might look to recoding your application to not use get_table, a 
memory hog.  Instead use step in a loop.


Jay Sprenkle wrote:

On 3/14/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:


Hi all,
I am having real problems with SQLite on Windows CE (.NET 4.1 and Pocket PC 
2003).




ret = sqlite3_get_table(db, "SELECT * FROM artic", &result, &rows, 
&cols, &errmsg);
if (ret != SQLITE_OK)
{
MessageBox(_T("Error en SQL"),_T("Error"),MB_OK);
sqlite3_free(errmsg);



You might call sqlite3_free_table(result) here. Without looking at the source
code it might have allocated a result even though there was an error.




return;
}
else {
MessageBox(_T("Erroron SQL sentence"),_T("Error"),MB_OK);
}
sqlite3_free_table(result);
sqlite3_close(db);
}




Did you look at the source code for sqlite3_get_table()?
It's easy to get and may be very helpful.




Re: [sqlite] SQLite memory leak on Windows CE

2006-03-14 Thread Jay Sprenkle
On 3/14/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hi all,
> I am having real problems with SQLite on Windows CE (.NET 4.1 and Pocket PC 
> 2003).

>  ret = sqlite3_get_table(db, "SELECT * FROM artic", &result, 
> &rows, &cols, &errmsg);
>  if (ret != SQLITE_OK)
>  {
>  MessageBox(_T("Error en SQL"),_T("Error"),MB_OK);
>  sqlite3_free(errmsg);

You might call sqlite3_free_table(result) here. Without looking at the source
code it might have allocated a result even though there was an error.


> return;
>  }
>  else {
>  MessageBox(_T("Erroron SQL sentence"),_T("Error"),MB_OK);
>  }
> sqlite3_free_table(result);
>  sqlite3_close(db);
> }


Did you look at the source code for sqlite3_get_table()?
It's easy to get and may be very helpful.


[sqlite] SQLite memory leak on Windows CE

2006-03-14 Thread [EMAIL PROTECTED]

Hi all,
I am having real problems with SQLite on Windows CE (.NET 4.1 and Pocket PC 
2003).
I have tried everything and it seems that there is a memory leak with SQLite on 
Windows CE.
I have test it with SQLite versions 3.2.2 and 3.3.4 and SQLite seems that it 
reserves memory and doesn´t free it after using it, memery is freed only after 
the main program has finished.
Take this simple example (it fails also with more complicated ones). I have 
test it using a quite big table (20,000 records).

Please i really need help, because my program consumes all the memory and i 
need to finish it next week:
Here is the sample source code to test (this is done with EVC   4.0 and a MFC 
application)
 void CMemoryMDlg::OnButton1() 
{
   char *errmsg;
   char **result;
   sqlite3 *db;
   int ret, rows, cols;

   int n = sqlite3_open("\\mysqlitebd.db", &db);
   if (db == 0)
   {
  MessageBox(_T("Error openning BD"),_T(""),MB_OK);
  return;
   }
   ret = sqlite3_get_table(db, "SELECT * FROM artic", &result, 
&rows, &cols, &errmsg);
   if (ret != SQLITE_OK)
   {
 MessageBox(_T("Error en SQL"),_T("Error"),MB_OK);
 sqlite3_free(errmsg);
 return;
   }
   else {
 MessageBox(_T("Error on SQL 
sentence"),_T("Error"),MB_OK);
    }
sqlite3_free_table(result);
    sqlite3_close(db);
}

Automóviles, telefonía, imagen y sonido, belleza... ¡encuentra gratis todo lo 
que necesitas! http://clasificados.wanadoo.es/