示例#1
0
/* effects: performs a garbage-collection */
void marksweep_collect()
{
  static int num_collections = 0;
  num_collections++;
  find_root_set();
  free_unreachable_blocks(&heap);
}
示例#2
0
/* msg threading algorithm, based on JWZ's algorithm,
 * http://www.jwz.org/doc/threading.html */
GHashTable*
mu_threader_calculate (MuMsgIter *iter, size_t matchnum,
		       MuMsgFieldId sortfield, gboolean descending)
{
	GHashTable *id_table, *thread_ids;
	MuContainer *root_set;

	g_return_val_if_fail (iter, FALSE);
	g_return_val_if_fail (mu_msg_field_id_is_valid (sortfield) ||
			      sortfield == MU_MSG_FIELD_ID_NONE,
			      FALSE);

	/* step 1 */
	id_table = create_containers (iter);
	if (matchnum == 0)
		return id_table; /* just return an empty table */

	/* step 2 -- the root_set is the list of children without parent */
	root_set = find_root_set (id_table);

	/* step 3: skip until the end; we still need to containers */

	/* step 4: prune empty containers */
	root_set = prune_empty_containers (root_set);

	/* sort root set */
	if (sortfield != MU_MSG_FIELD_ID_NONE)
		root_set = mu_container_sort (root_set, sortfield, descending,
					      NULL);

	/* step 5: group root set by subject */
	/* group_root_set_by_subject (root_set); */

	/* sort */
	mu_msg_iter_reset (iter); /* go all the way back */

	/* finally, deliver the docid => thread-path hash */
	thread_ids = mu_container_thread_info_hash_new (root_set,
							matchnum);

	g_hash_table_destroy (id_table); /* step 3*/

	return thread_ids;
}
示例#3
0
/* effects: performs compacting garbage collection on heap,
   flips semi-spaces, and updates the heap occupancy statistics.
*/
void copying_collect()
{
  static int num_collections = 0;
  void *scan;
  float occupancy;

  setup_for_threaded_GC();

  scan = heap.to_free;

  find_root_set();

  while(scan < heap.to_free)
    {
      // trace object at scan for references,
      // then increment scan by size of object
      assert(scan != NULL && ((jobject_unwrapped)scan)->claz != NULL);
      trace((jobject_unwrapped)scan);
      scan += align(FNI_ObjectSize(scan));
    }
  assert(scan == heap.to_free);

  // free up any resources from inflated objs that have been GC'd
  deflate_freed_objs(&heap);

  // flip semi-spaces
  flip_semispaces(&heap);

  // this function is a nop if not debug
  debug_overwrite_to_space(&heap);

  // calculate heap occupancy after compacting garbage-collection
  occupancy = ((float) (heap.from_free - 
			heap.from_begin))/((float) heap.heap_size);
  heap.avg_occupancy = (heap.avg_occupancy*num_collections +
			occupancy)/(num_collections + 1);
  num_collections++;

  error_gc("GC number %d\n", num_collections);

  cleanup_after_threaded_GC();
}