Hi,
I can't figure out why the following is leaking memory - when I run the application the memory usage just keeps going up. Anyone see something wrong with this code:
I'm adding some initial values to the 2d deque like so:
And then during the running of the application, the user periodically performs actions that invoke this:Code:deque<deque<MyType*> > dq;
for(int i = 0; i < 10; i++) {
dq.push_back(deque<MyType*>());
for(int j = 0; j < 10; j++) {
dq[i].push_back(new MyType(1,2));
}
}
or this:Code:for(int j = 0; j < 10; j++) {
delete dq.back()[j];
}
dq.pop_back();
dq.push_front(deque<MyType*>());
for(int j = 9; j >= 0; j--) {
dq.front().push_front(new MyType(1,2));
}
Much thanks for any help!Code:for(int i = 0; i < 10; i++) {
dq[i].push_front(new MyType(1,2));
delete dq[i].back();
dq[i].pop_back();
}