views:

211

answers:

1

Running on Solaris 10, I am having problems when I hit a LOG.debug statement using an Apache Log4j logger. The basic scenario is demonstrated in the following code block:

public class MyClass {
   private static final Logger LOG = Logger.getLogger(MyClass.class.getName());
   private LinkedHashMap<String, String> myMap = 
         new LinkedHashMap<String, String>();

   public static void main(String[] args) {

      // A really long String, but certainly not exceeding 2^31 - 1 characters 
      //long
      String reallyLongString = "A really, really, really...long String";
      String key = "keyToReallyLongString";

      // When this line is executed, Solaris instantly and completely logs me off 
      // of the system
      LOG.debug("Adding to myMap[" + key + "]: " + reallyLongString);
   }
}

Any thoughts?

+1  A: 

If you have any type of process limits, you might be running into them. By doing that string concatenation, you will use at least (reallyLongString.length() + key.length()) * 2 bytes. If that is enough to push you over your limits…

Paul Wagland
Although I still don't think the string length is an issue (given the calculation you gave, it would be about 27,000 characters), I think you're on to something. On further investigation, I only seem to be able to duplicate this issue when running from within the Eclipse IDE. Is there a particular memory setting that you recommend looking at? Or, is there a setting specific to Eclipse Rich Client Platform applications of which I am unaware?
Adam
@Adam: I am afraid not… I have never actually seen this issue, and was just throwing out ideas to see if it helped.
Paul Wagland