Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » GridControl release memory (GridCtrl unable to reset memory usage)
GridControl release memory [message #49061] |
Mon, 11 December 2017 07:56 |
chis.adrian
Messages: 3 Registered: December 2017 Location: Romania
|
Junior Member |
|
|
Hi,
I have the following function:
void SelSqliteQuery( GridCtrl * MyGridCtrl ,std::string Qstr)
{
MyGridCtrl->RemoveColumn(0,MyGridCtrl->GetColumnCount() );
MyGridCtrl->Reset();
MyGridCtrl->Ready(false);
sqlite3 * db;
if (sqlite3_open_v2(path_db.ToString().ToStd().c_str(),&db,SQLITE_OPEN_READWRITE,NULL)!=SQLITE_OK)
{
PromptOK("Can't create or open database file\n");
return;
}
const char *quer = Qstr.c_str();
sqlite3_stmt *statement;
if(sqlite3_prepare_v2 (db, quer, -1, &statement, 0) != SQLITE_OK)
{
PromptOK("sqlite3_prepare_v2 FAILED \n");
return;
}
int rows=0;
int cols = sqlite3_column_count(statement);
for (int CC=0;CC<cols;CC++)
MyGridCtrl->AddColumn( (char*)sqlite3_column_name(statement, CC));
while(true)
{
if( sqlite3_step(statement) == SQLITE_ROW)
{
for(int col = 0; col < cols; col++)
MyGridCtrl->Set(rows,col, (char*)sqlite3_column_text(statement, col));
rows++;
} else break;
}
sqlite3_finalize(statement);
sqlite3_close(db);
MyGridCtrl->Ready(true);
}
Well it work and its fast nice,
Problem is that this function is called many times as I want to create a small data base browser.
(I checked the function in other C++ app and for what I can tell ain't leaking)
Now when I select a big table memory goes up 400 mb acceptable its big but when I select a smaller one
memory remains same usage.
How can I reset ,delete ,clear whatever the memory usage.
Thank You.
|
|
|
|
|
Re: GridControl release memory [message #49064 is a reply to message #49063] |
Mon, 11 December 2017 10:27 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
chis.adrian wrote on Mon, 11 December 2017 10:06Thank You,
I understand I was afraid of this answer since I saw on other C,C++ Grid,Table ... implementations.
Anyway is there a way to access Grids Vector<Vector (Exposed) so I can try shrink it my self?
I already done it in a C program and new C++ has std::vector::shrink_to_fit maybe I can use it.
Ah, you do not understand. That would not help. Memory is correctly released, there are no leaks and nothing to be shrunk.
However, that released memory is kept in reserve by U++ memory management subsystem (aka "memory allocator") for further allocations.
The reason is that a) retrieving memory from system is somewhat expensive b) U++ allocator "formats" memory blocks, which is something that can be avoided if memory is kept in reserve instead being returned to the system and then retrieved again
(and then there is that technical problem with Win32, which only allows limited granularity)
|
|
|
|
Goto Forum:
Current Time: Fri Mar 29 06:55:30 CET 2024
Total time taken to generate the page: 0.01260 seconds
|