From here, I know the spring becomes heavier when potential energy stores in it , how about gravitional potential energy? Is the case similar?consider a puffy object, eg, a gas giant, when it contracts, the gravitional potential energy of all atoms decreases because the radius decreases, does it also causes the mass of the gas giant decrease?
2 Answers
The act of contracting converts potential energy into kinetic energy or heat, so the answer in this case is no difference, though the somewhat hotter contracted planet does lose heat (and mass) faster, but the actual contracting should be zero change in system energy.
This is consistent with Newton's energy can't be destroyed theorem. The only energy that leaves the system leaves by thermal radiation (though I suppose, the teeny-tiny'est amounts of energy leave by gravitation waves). so the contracting might lose fractions of fractions of fractions of an ounce by gravity-waves, but that's pretty much negligible.

- 5,658
I think userLTK's answer pretty much covers your question, but I would add a footnote for clarification.
Your question is a bit unclear because you don't say whether you're asking:
- does the process of contraction lose mass?
or
- is a contracted object lighter once it has reached equilibrium?
As userLTK says, the process of contraction does not cause a mass loss, however the contraction will heat up the contracting object, and as the contracted object cools it loses mass. Suppose as the contracted object cools it loses an energy $E$, then the mass lost will be $E/c^2$, i.e. as described by Einstein's famous equation $E=mc^2$.
Measuring this for astronomical objects is obviously hard, but for more manageable objects like atoms it is easily measureable. For example the mass of a hydrogen atom is smaller than the mass of an electron plus the mass of a proton. The difference in mass is 13.6eV, which is the ionisation energy of the hydrogen atom i.e. the energy radiated away when a free electron and proton combine to form hydrogen.

- 355,118