wxSQLite3 and clearing results... Topic is solved

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
Post Reply
baka_bai
Experienced Solver
Experienced Solver
Posts: 99
Joined: Fri Sep 30, 2005 10:20 pm
Contact:

wxSQLite3 and clearing results...

Post by baka_bai »

After querying a db file and assigning my results to a wxSQLite3ResultsSet object how would I clear the results?


Could I get away with doing something like this:

Code: Select all

void DBClass::ClearResults() {
    delete m_results; //m_results private variable
}
or will that cause a memory leak?
Or can I just reasign a new query to m_results?

The reason I ask this would be because the user, in my app, may sometimes not require the viewing of all results sent back in my app. So I do not want any wasted memory if a search of the database my not happen again for a duration of time.
utelle
Moderator
Moderator
Posts: 1128
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxSQLite3 and clearing results...

Post by utelle »

baka_bai wrote:After querying a db file and assigning my results to a wxSQLite3ResultsSet object how would I clear the results?
Memory is cleaned up when the wxSQLite3ResultsSet object goes out of scope, when you explicitly call its method Finalize, or when you assign a new value.

baka_bai wrote:Could I get away with doing something like this:

Code: Select all

void DBClass::ClearResults() {
    delete m_results; //m_results private variable
}
or will that cause a memory leak?
No.
baka_bai wrote:Or can I just reasign a new query to m_results?
Yes.
baka_bai wrote:The reason I ask this would be because the user, in my app, may sometimes not require the viewing of all results sent back in my app. So I do not want any wasted memory if a search of the database my not happen again for a duration of time.
Do whatever is most appropriate in your application, that is, explicitly call Finalize, assign a new value or delete the result set. wxSQLite3 takes care of cleaning up the memory allocated by SQLite.

Regards,

Ulrich
baka_bai
Experienced Solver
Experienced Solver
Posts: 99
Joined: Fri Sep 30, 2005 10:20 pm
Contact:

Post by baka_bai »

thanks for clearing that up utelle.
Post Reply