As CPallini has already pointed out, you are attempting to clear a 3-dimensional array of int's with 256 million elements, in other words roughly 1 gigabyte of memory!
There are several ways to optimize that:
(a) Use a linear int array instead, and do the index calculations manually (that's what most people in image processing do in their 2D arrays). Then you can clear that memory with a single call to memset, which is more efficient than clearing nested vector<...>. The performance gain will be limited, though. Perhaps a factor of 2 or 3 if you are lucky.
For example:
int* pArray = new int [1024 * 512 * 512];
memset (pArray, 0, sizeof (int) * 1024 * 512 * 512);
int cellValue = pArray [x + 512*y + 512*512*z];
(b) Rework your problem, so that you don't need 256 million cells. That would be the best alternative if that is possible.
(c) If your 3D matrix is sparsely filled, divide your huge array up into subcubes of say 16x16x16 cells and allocate only space for those subcubes that contain values unequal to zero. That not only saves a lot of memory, but also a lot of time clearing that memory. Using a power of 2 for the edge size of the subcubes is advantageous as it simplifies the calculation of the subcube index. Cell (x, y, z) will be found in subcube (x>>4, y>>4, z>>4), a very fast operation. Inside that subcube the cell has the index (x & 0xf, y & 0xf, z & 0xf).
This is quite a bit of work, but for huge problems it sure is worth the effort.
AMENDED 5-Jan-2013:
In a comment to another post you let us know that you are storing a set of images. In that case it makes sense to arrange you data like that:
std::vector<Image*> images;
where Image is a class that holds a single image as a 2D array of pixel values. That way you can add or remove images from that set without deleting the entire storage. This is basically making use of technique (c) shown above, and choosing an image as a subcube.
You mentioned that you would be using multi-threading to operate on the images. Then you could use a locking technique that locks an entire image for one of your threads. That is also a lot easier to implement in a vector of images than in your 3D array approach.
Also: If you are storing images you probably don't want to have
int
as the type for a single pixels. Most likely your pixels are 8-bit quantities, or 3 x 8-bit RGB values. Your image class will probably solve this problem for you. Google for one of the many image classes that are in the public domain and it will take a lot of work off your shoulders.