TreeMap

Timothy Stack stack at cs.utah.edu
Tue Sep 26 14:50:45 PDT 2000


> I've checked in that patch.. but here's a question.  Why doesn't
> kaffe (with the old TreeMap) run out of memory when the program
> below is run? Maybe just chance?

> 		TreeMap t = new TreeMap();
> 		for (int i = 0; i < 10000000; i++) {
> 			Integer value = new Integer(r.nextInt() % 37);
> 			if (r.nextBoolean())
> 				t.put(value, null);
> 			else
> 				t.remove(value);
> 		}

Its randomly removing nodes and its only allocating Integer's so it
shouldn't run out of memory to quickly.

Actually, the TreeMapLeak test was bad (doh!).  Since it never removed
anything the bug never came into play, so it most likely ran out of
memory because of stale reference to the tree, which was eventually
clobbered.  Anyways, a fixed TreeMapLeak showed that the patch did work,
thanks!

> -Archie

tim


More information about the kaffe mailing list