strange memory leak

Pages: 12
Aug 8, 2010 at 4:49pm
Doesn't nodeTo() allocate memory? It's returning objects without being passed any container structure, so either it's allocating memory, or it's retuning pointers to a static or global container.
Last edited on Aug 8, 2010 at 4:50pm
Aug 8, 2010 at 4:56pm
You're right, it's doing the latter. Not allocating new memory, but returning a pointer to one of the nodes in a 2-dimensional array, which is an instance variable of the Maze2d class that this method is a part of.

This is so totally weird I can't get over it. Whenever I comment out all the push_back and erase calls, the memory stays perfectly constant and well-behaved! So it "has" to be those function calls, but in theory they should not be doing any allocation...
Aug 8, 2010 at 11:15pm
Just a question: when you call your std::cout methods, you call some overloaded operators (which, no doubt, do memory allocation). Did you try testing the return values of vector::capacity() through the debugger *only*?
Last edited on Aug 8, 2010 at 11:15pm
Aug 9, 2010 at 3:04am
@tition: Yeah, I did indeed try that. It never changes.
Topic archived. No new replies allowed.
Pages: 12