What is considered a small object in C ++?

I read about the distribution of small objects in "Modern C ++ Design". Andrei Alexandrescu claims that general-purpose operators (new and remote) do not work well for allocating small objects.

In my program there are many objects created and destroyed in a free store. These objects measure over 8000 bytes.

What size is considered small? Are 8000 bytes small or large when it comes to memory allocation in C ++?

+5
source share
4 answers

The definition of โ€œsmallโ€ changes, but, generally speaking, an object can be considered โ€œsmallโ€ if its size is smaller than the overhead in size caused by the distribution of the heap (or at least close to this size).

Thus, a 16-byte object is probably considered "small" in most cases. A 32-byte object can be considered small under certain special circumstances. An 8,000-byte object is definitely not "small."

Usually, if you are faced with the problem of using a small allocator object, you want to improve the performance of some block of code. If using a small object allocator doesn't help your performance, you probably shouldn't use it.

+13
source

[...] , ( ) .

. . Linux - AVL GNU std:: map, - . , std:: map . std:: map .

, .

. - , , .

, / . , .

8000 . ? 8000 , ++?

. , 8K, . .

, , , . .

P.S. , 8K . - . , 10 + . 10 , , , .

+3

, , 8000 "". , , , , - , , , , KennyTM, , ++- .

+1

, , , new/delete? , , .

0
source

All Articles