Context. In previous papers it was shown that the function Γ(M, EOS) ≡ αβ GR /Λ 0.8 (R) is invariant (≈0.40) for pre main-sequence stars (PMS), white dwarfs (WD), and for neutron stars (NS) computed with equations of state using relativistic mean-field nucleon interactions. The form-factors α GR and β GR are related to the relativistic gravitational potential energy and the moment of inertia and are a key to handling the Jacobi virial equation, which is a powerful tool for investigating the stellar internal structure and evolution. We also found that Γ(M, EOS) is invariant for gaseous planets. Moreover, a macroscopic criterion of stability for NS was derived. Aims. To test if the invariance of Γ(M, EOS) also holds for an equation of state (EOS) in the non-relativistic framework, we compute NS models by adopting four different EOS prescriptions. We also computed models for hybrid and pure quark stars to extend the range of validity of the Γ(M, EOS) memory effect. To complete the three known final scenarios for stellar evolution, we follow the core-collapse supernova until the onset of formation of a black hole. Methods. Calculations from the PMS up to the WD stages were performed using the MESA code. Neutron, hybrid, and pure quark star models were computed using a modified version of the NSCool/TOV subroutines. The core-collapse supernova simulation was carried out using the code AGILE-IDSA. The relativistic moment of inertia and gravitational potential energy were computed through a fourth-order Runge-Kutta method. Results. We confirm that the function Γ(M, EOS) is invariant for PMS, WD, NS, hybrid, and pure quark stars and is independent of the mass and of the EOS (relativistic and non-relativistic frameworks). We show that our macroscopic criterion of stability is also valid for all mentioned compact stars. In a core-collapse supernova simulation, the PMS value of Γ(M, EOS) is recovered at the onset of formation of a black hole. Therefore, we conclude that, regardless of the final products of the stellar evolution, white dwarfs, neutron/hybrid/quark stars or proto-neutron star at the onset of formation of a black hole, they present a memory effect and recover the fossil value of Γ(M, EOS) ≈ 0.40, acquired during the PMS. Finally, we have shown the invariance of Γ(M, EOS) for earth-like planets as well.