Interview frequency: …
Short answer
It replaces a method call with the method body to avoid Call Stack and processor branch costs; use it for very small, fast methods on critical paths.
Explanation
The JIT automatically inlines small methods below a certain size. A regular call pushes parameters onto the Stack and jumps through the processor's Call/Return path. AggressiveInlining asks the JIT to insert the method body directly into the caller. Overusing it on large methods can bloat machine code (Code Bloat) and push code out of the fast processor cache (L1/L2 Instruction Cache).
Code example
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int FastMax(int a, int b) => a > b ? a : b;Common mistakes
- Applying AggressiveInlining to large, complex methods with exceptions, reducing cache efficiency and performance.