Magnesium is typically related to the detergent additive packages commonly used in engine oils. Detergents are used in lubricants to aid in control of deposits and help keep contaminants suspended in the oil so they can be carried to the filter and removed. In addition, some detergent chemistries also neutralize the acidic by-products of combustion. In doing so, they function as corrosion inhibitors.