deleting dynamic array

I have the following code:

1
2
3
4
5
6
7
8
9
10
const float phantom_res = 500;
const int depth = phantom_res;  //x
const int height = phantom_res; //y
const int width = phantom_res;  //z

float* phantom_energy = new float[height*width*depth];
delete[] phantom_energy;

cout << "Done!" << endl;
system("pause");


When I run my program, it just stays idle and "Done!" never appears on the screen. It seems that my array is not being deleted! Not good. Any ideas about what is going on. Between the line where I create the array and the line where I delete, I populate the array and read off the information. There might be something going on there. Please help.
a) Don't use system() commands.
b) Can you show us the rest of the code? It's quite odd to see a cout without its context. The way you posted it, it seems like everything is just placed in the global scope, which of course makes no sense.
c) Don't use system() commands!
d) If you're just testing, try a lower value for phantom_res. An array of 500^3 floats is not a good idea, memory-wise. Even on the heap.
Topic archived. No new replies allowed.