In a closed or isolated system:
For a continuous or steady-state process: Total Mass in = Total Mass out irrespective of the process involves a chemical reaction or not
For a batch or semi-batch reactive as well as non-reactive process: Total Mass in - Total Mass out = Total Mass accumulated irrespective of the process involves a chemical reaction or not
Conservation of mass forms basic equation in disciplines like chemical engineering and for an isothermal process.
For very energetic systems the conservation of mass-only is shown not to hold, as is the case in nuclear reactions and particle-antiparticle annihilation in particle physics.
Mass is also not generally conserved in open systems. Such is the case when various forms of energy and matter are allowed into, or out of, the system. However, unless radioactivity or nuclear reactions are involved, the amount of energy escaping (or entering) such systems as heat, mechanical work, or electromagnetic radiation is usually too small to be measured as a decrease (or increase) in the mass of the system.
For systems where large gravitational fields are involved, general relativity has to be taken into account, where mass-energy conservation becomes a more complex concept, subject to different definitions, and neither mass nor energy is as strictly and simply conserved as is the case in special relativity.
The change in mass of certain kinds of open systems where atoms or massive particles are not allowed to escape, but other types of energy (such as light or heat) are allowed to enter or escape, went unnoticed during the 19th century, because the change in mass associated with addition or loss of small quantities of thermal or radiant energy in chemical reactions is very small.
The conservation of relativistic mass implies the viewpoint of a single observer (or the view from a single inertial frame) since changing inertial frames may result in a change of the total energy (relativistic energy) for systems, and this quantity determines the relativistic mass.
For the special type of mass called invariant mass, changing the inertial frame of observation for a whole closed system has no effect on the measure of invariant mass of the system, which remains both conserved and invariant (unchanging), even for different observers who view the entire system.
The mass-energy equivalence formula gives a different prediction in non-isolated systems, since if energy is allowed to escape a system, both relativistic mass and invariant mass will escape also. In this case, the mass-energy equivalence formula predicts that the change in mass of a system is associated with the change in its energy due to energy being added or subtracted as per Einstein's equation.