added code for printing when system.gc  iscalled