To understand the physics of solar flares, including the local reorganization of the magnetic field and the acceleration of energetic particles, we have first to estimate the free magnetic energy available for such phenomena, which can be converted into kinetic and thermal energy. The free magnetic energy is the excess energy of a magnetic configuration compared to the minimum-energy state, which is a linear force-free field if the magnetic helicity of the configuration is conserved. We investigate the values of the free magnetic energy estimated from either the excess energy in extrapolated fields or the magnetic virial theorem. For four different active regions, we have reconstructed the nonlinear force-free field and the linear force-free field corresponding to the minimum-energy state. The free magnetic energies are then computed. From the energy budget and the observed magnetic activity in the active region, we conclude that the free energy above the minimum-energy state gives a better estimate and more insights into the flare process than the free energy above the potential field state.