c++ - Memory increasing in my app -



c++ - Memory increasing in my app -

i learning c++ , need little advice on how clean memory when not using pointers.

i have background blackberry 10 app has memory limit of 3mb before gets stopped, app beingness stopped because of hitting limit , having problem finding figuring out why.

i have narrowed downwards increasing of memory function - if don't phone call function memory doesn't increase.

the function uses qvariant, qvariantlist, qvariantmap, qstring declared outside function when class created (i.e qvariantmap map), before access these objects in function phone call .clear() on each of them of understanding should clean memory held, using int in function declared outside of it.

the function quite big , calling other functions have provided snippet below of doing in case wrong others.

bindings.clear(); bindings["name"] = name; result.clear(); result = sqlda->execute(sqlqueryz, bindings); if (!sqlda->haserror()) { if( !result.isnull() ) { list.clear(); list = result.value<qvariantlist>(); recordsread = list.size(); for(int iii = 0; iii < recordsread; iii++) { map.clear(); map = list.at(iii).value<qvariantmap>();

any help appreciated.

calling .clear() on qlist or on qmap clears list not free objects in list, illustration if have:

qlist<qobject *> list; qobject *c = new qobject(); c->setobjectname("object_a"); list.append(c); qobject *b = new qobject(); b->setobjectname("object_b"); list.append(b); qdebug() << list.count(); //here 2 list.clear(); qdebug() << list.count(); //here 0; qdebug() << a->objectname(); // here "object_a"

this means after .clear() ojects still living in memory

what should when want rid of objects in list is:

while (list.count() > 0) delete list.takefirst();

and here list.clear() redundant.

c++ qt blackberry-10

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

java - Parsing XML, skip certain tags -

c# - ASP.NET MVC Sequence contains no matching element -