|
|
|
|
|
by adgjlsfhk1
1385 days ago
|
|
This is one of several places. Some others are. You don't know how much memory an object of a given type takes to instantiate. This makes object allocation slower. This also means that you can't allocate a Vector<T> inline. It has to be a vector of pointers. You don't know what fields a type has. This makes GC scanning more expensive. You can't optimize the layout of a type. If you know an object doesn't have subtypes, you can move it's fields around to reduce padding. If you want to be able to look up fields quickly, you need to put all the fields of the supertype first in memory which will increase the size of your objects. |
|
On OOP languages with GC, you can reduce GC scanning by having precise GC, and if the languages support value types by making use of structs with method pointers.
With the help of PGO for AOT or the JIT, the compiler can optimize the layout of types for the target architecture.