This code looks like using all the system memory. Why does it happend?
sql::Statement *Query;
sql::ResulSet *Result;
while(1){
Query = con->createStatement();
Result = Query->executeQuery("SELECT `Some` FROM `Table` LIMIT 1");
Result->next();
Result->close();
Query->close();
cout << "console message..." << endl;
//delete Query; SEGFAULT
}
If i comment all the lines except the cout the memory doesn't get filled. But using the SQL looks like Query = con->createStatement; is not replacing the old Query value and Result = bla; is not replacing the old value
Well it looks like there is no info on google. I found what was the problem.
as SJuan76 said each call to createStatement and to executeQuery is a new object
So i started to do a lot of tryes and i figure out of the following
So the code to get the "forever running" program to use always the same memory shoud look like this
sql::Statement *Query;
sql::ResulSet *Result;
Query = con->createStatement();
while(1){
if(!Result->isClosed()) Result->close();
delete Result;
Result = Query->executeQuery("SELECT `Some` FROM `Table` LIMIT 1");
Result->next();
cout << "console message..." << endl;
}