This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Nicolas Wack wrote:
Hi all!
I have a little problem, and I thought maybe someone could help me out before I go crazy!!
Here's a simple file that allocates some amount of memory (roughly 300MB), sleeps for 5 secs, deallocates it and sleeps for 15 seconds.
I know for sure that the program goes through all the destructors, however nothing gets freed...
define 'freed'. Do you mean 1) returned to the program's free memory pool? 2) returned to the OS?
Unless you do something system specific, #1 is what will happen (because that's what the standard says should happen)
nathan
#include <iostream> #include <vector> using namespace std; const unsigned int N = 300000; int main() { vector<float*> v(N); for (uint i=0; i<N; i++) { v[i] = new float[256]; } cout << "1st step" << endl; sleep(5); for (uint i=0; i<N; i++) { delete v[i]; } cout << "2nd step" << endl; sleep(15); return 0; }
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |