[classad-users] Constant cache causes memory overflow


Date: Mon, 4 Jun 2007 02:27:13 +0900
From: "Hidemoto Nakada" <hide-nakada@xxxxxxxxxx>
Subject: [classad-users] Constant cache causes memory overflow
Hello,
I'm new to this list.

We are using ClassAd as a policy description language
and during the test of the system,
we found that the system always exits because of
OutOfMemory Error of Java VM, when the evaluation
is repeated several million times.

We have investigated the code and found that
the Constant cache code shown  below is causing
the error. The instanceMap is a static variable,
that means it will not be destroyed forever, and
it keeps growing, since there are no code to
shrink it.

  private static final Constant getInstance(Object val, int type) {
      Constant result = (Constant) instanceMap.get(val);
      if (result == null) {
          result = new Constant(val, type);
          instanceMap.put(val, result);
      }
      return result;
  }

IMHO, this kind of cache mechanism is no longer needed,
since the cpu is fast enough.
Tha Java wrapper classes, say Integer, does this but just for
very limited number of numbers; from -100 to  100.
--
  HIDEMOTO NAKADA, GTRC, AIST
[← Prev in Thread] Current Thread [Next in Thread→]
  • [classad-users] Constant cache causes memory overflow, Hidemoto Nakada <=