He has a few things to say about the problems. Page 198:
C ++ programmers often allocate a large block of memory (using malloc) and then use chunks at the same time to store multiple calls to malloc. This is not recommended for managed code for several reasons:
- Managed memory allocation is a fast operation, and the garbage collector has been optimized for extremely fast allocations. The main reason for preallocating memory in unmanaged code is to speed up the allocation process. This is not a question for managed code.
- If you preallocate memory, you invoke more allocations than necessary; This can cause unnecessary garbage collection.
- The garbage collector cannot recover the memory that you manually recycle.
- Predefined memory grows and costs more processing time when it is eventually released.
source share