Your code allocates 10 blocks of memory with the size of int (read: it can store 10 ints in the memory you new'd). When you delete pData, you're only deleting 1 of those ints (I believe the first one). You still have 9 left over. So yes, you have a memory leak.

When using delete[], you needn't worry about the size of the memory, it will free everything (?) that was new'd for pData.

Another alternative is to use C++ smart pointers so that you don't have to worry about deleting (I believe it's already set up in it's destructor).

When you delete pData, you're only deleting 1 of those ints (I believe the first one). You still have 9 left over. So yes, you have a memory leak.

Not exactly, it's just undefined behavior. Chances are that you will just crash the program or corrupt the heap. For some implementations (e.g. when it maps directly to free()) all memory might be freed correctly, however no constructors would be called.

Either way, you must use delete when you used new and delete[] when you used new[].

Well, at least in the case of VC++, there will be no memory leaked by forgetting the [] when you call delete to free up an array of ints. But I would code it with the [] for consistency with the cases that do require it.

You see, the call

int *pData = newint[nWidth];

leads to
- the allocation of a single block of nWidth * sizeof(int) bytes (big enough for all elements)
- the default constructor being called on each element (which doesn't do a lot, as it's an int)

delete [] pData;

results in
- the destructor being called on each element (which doesn't do anything...)
- the (single) block being freed

If you forget the [], the destructor is only called on the first element. But the single block is still freed, so the base memory is handled OK. As the int destructor does nothing, there's no real difference (as far as memory goes)

But leaks will happen if the element is a class that allocates dynamic memory or some other resource. The bottom line is that you should always use the [] out of habit, so you never forget it when it's needed!

2. Other compilers might do something different, but allocating a single block to hold all the elements is going to be a pretty common approach given the way memory is managed (remember, new must allocate the array elements in contiguous memory)