J_Gc.c
void jGC_sweep(){
  int i, killed = 0, alive = 0;
  for(i=0;i<vmhSize;i++){
	if(vmHeap[i].used){
	  J_UtfString tmp;
	  J_Class* jc = J_OBJ_CLASS(i);
	  
	  if(!vmHeap[i].marked){
		
		if(GC_DBG & 0x02)
		  if(jc!=NULL){tmp = jGetClassName(jc,jc->thisClassIdx); printf("DESTROY object[%d] : %s\n",i,tmp.str);}
  
        freeObject(i);
		killed++;				/* some statistic */
		continue;
	  }

	  if(jc==NULL){
		if(GC_DBG)
		  printf("alive array[%d]: len = %d, type = %d\n",i,J_ARRAY_LEN(i),J_ARRAY_TYPE(i));
	  } else {
		if(GC_DBG){
		  tmp = jGetClassName(jc,jc->thisClassIdx);
		  printf("alive object[%d] : %s\n",i,tmp.str);
		}
	  }
	}
	vmHeap[i].marked = 0;
	alive++;					/* some statistic */
  }

  if(GC_DBG) printf("GC: killed: %d, alive: %d\n",killed,alive);
}
/**
 *  Sweep (free) all unused objects from the heap
 */
Sweep (free) all unused objects from the heap
Sweep ( free ) all unused objects from the heap
void jGC_sweep(){
  int i, killed = 0, alive = 0;
  for(i=0;i<vmhSize;i++){
	if(vmHeap[i].used){
	  J_UtfString tmp;
	  J_Class* jc = J_OBJ_CLASS(i);
	  if(!vmHeap[i].marked){
		if(GC_DBG & 0x02)
		  if(jc!=NULL){tmp = jGetClassName(jc,jc->thisClassIdx); printf("DESTROY object[%d] : %s\n",i,tmp.str);}
        freeObject(i);
		killed++;				
		continue;
	  }
	  if(jc==NULL){
		if(GC_DBG)
		  printf("alive array[%d]: len = %d, type = %d\n",i,J_ARRAY_LEN(i),J_ARRAY_TYPE(i));
	  } else {
		if(GC_DBG){
		  tmp = jGetClassName(jc,jc->thisClassIdx);
		  printf("alive object[%d] : %s\n",i,tmp.str);
		}
	  }
	}
	vmHeap[i].marked = 0;
	alive++;					
  }
  if(GC_DBG) printf("GC: killed: %d, alive: %d\n",killed,alive);
}
void jGC_sweep ( ) { int i , killed = 0 , alive = 0 ; for ( i = 0 ; i < vmhSize ; i ++ ) { if ( vmHeap [ i ] . used ) { J_UtfString tmp ; J_Class * jc = J_OBJ_CLASS ( i ) ; if ( ! vmHeap [ i ] . marked ) { if ( GC_DBG & 0x02 ) if ( jc != NULL ) { tmp = jGetClassName ( jc , jc -> thisClassIdx ) ; printf ( " \n " , i , tmp . str ) ; } freeObject ( i ) ; killed ++ ; continue ; } if ( jc == NULL ) { if ( GC_DBG ) printf ( " \n " , i , J_ARRAY_LEN ( i ) , J_ARRAY_TYPE ( i ) ) ; } else { if ( GC_DBG ) { tmp = jGetClassName ( jc , jc -> thisClassIdx ) ; printf ( " \n " , i , tmp . str ) ; } } } vmHeap [ i ] . marked = 0 ; alive ++ ; } if ( GC_DBG ) printf ( " \n " , killed , alive ) ; }
Sweep (free) all unused objects from the heap
Sweep ( free ) all unused objects from the heap
/* some statistic */ /* some statistic */