If m2 is shifted by a distance x and released, the mass m1 will break off from the wall when the spring restores its natural length and m2 will start going towards right. At the time of breaking m1, m2 will be going towards right with a velocity v, which is given as
12kx2=12m2v2⇒v=(√km2)x
and the velocity of the centre of mass at this instant is
vCM=m1×0+m2×vm1+m2=(√m2k)xm1+m2