I am writing a C++ application which will require a block of memory (about 1000 bytes) as a temporary buffer for some text processing. The operation may be repeated up to 10,000 times a second.
Could anybody confirm that it would be more expensive to allocate the memory each time I need the buffer (i.e. new with a smart pointer, memory is deallocated when out of scope), than to have a fixed buffer and clear it (write every byte of it with a zero) every time the processing is complete?
It sounds like common sense for C++ but I just cannot find anything on the internet which confirms it.
Is the situation different for computer languages with automatic garbage collection facilities (e.g. Java, .net)?