# Disable or Decrease the Amount of Inlining

Inlining replaces a call to a function with the body of the function. This lets the compiler optimize the code for the inlined function in the context of its caller, usually yielding more specialized and better performing code. This also removes the overhead of calling the function at run-time.

However, replacing a call to a function by the code for that function usually increases code size. The code size increase can be substantial. To eliminate this code size increase, at the cost of the potential performance improvement, inlining can be disabled.

As an alternative to completely disabling inlining, the default amount of inlining can be decreased by using an inline factor less than the default value of 100. It corresponds to scaling the default values of the main inlining parameters by n%.

Options to specify:

To disable inlining: | Linux* and macOS*: -fno-inline Windows*: /Ob0
To reduce inlining and factor the main inlining parameters: | Linux* and macOS*: -inline-factor=n Windows*: /Qinline-factor:n
To fine tune the main inlining parameters: | Linux* and macOS*: -inline-factor -inline-max-per-compile -inline-max-per-routine -inline-max-size -inline-max-total-size -inline-min-size Windows*: /Qinline-factor /Qinline-max-per-compile /Qinline-max-per-routine /Qinline-max-size /Qinline-max-total-size /Qinline-min-size

For further details about the compiler options, see the compiler option descriptions.

Advantages of this method: | Disabling or reducing this optimization can reduce code size.
Disadvantages of this method: | Performance is likely to be sacrificed by disabling or reducing inlining especially for applications with many small functions.

Parent topic: Methods to Optimize Code Size