In my application there are some cases that relatively small objects, (max 50 bytes) e.g. message classes for logging purposes, must be created and freed (by GC) frequently during the execution of the program. So I am worried about the overhead of dynamic allocation of these objects. As stated in this question there are some usable fast memory allocators for native code.
Is there a concept of fast memory allocation in .Net or is fast memory allocation needed in .Net? If not what can be used to speed up that kind of implementation? (Maybe some kind of a preallocated object pool.) Should I worry about the overhead?
In my application there are some cases that relatively small objects, (max 50 bytes)
Share
As it behooves a well designed memory allocator, there is only one way to allocate garbage collected memory. It is very fast, allocating merely requires adjusting a pointer. Much faster than the allocator that native code has to use. Which has a much more difficult job to do, once native memory is allocated it cannot be moved anymore. Which makes it hard to write an allocator that doesn’t suffer from fragmentation. The counter-measures add overhead. Not an issue in a GC heap, it can compact.
You cannot improve on the speed of the GC allocator.