Memory occupied by functions

I have a Voxel class that is created half a million times. I have reduced the amount of data that I use, but it just occurred to me that I’m not sure that functions take up memory in the same way as variables. How to find out the amount of space that a function performs in my program? More importantly, when I have 500 instances of a class, does this mean that I have 500 instances of a function?

I can guess that this is most likely not the case (excluding the built-in functions), but the explanation would be nice.

+3
source share
4 answers

. ( , inline ) .

, .

instantiation . , -, . .

Visual Studio , , , , -time, , . /OPT: REF , . Release, .

+4

- , - . .

+2

, . .

. , .

+2

, , . , - "", , a this.

, ,

struct A { int x; void foo(); };

struct A {};
void foo( A* self );

.

, vtable, .

+1
source

Source: https://habr.com/ru/post/1779488/


All Articles