It is because of constant class loading.
Java stores class byte code and all the copnstants (eg string constants) in permament heap that is not garbage collected by default (which make sense in majority of situations because classes are loaded only once during the liftime of an application).
In applications chat often load classes during an entire liftime that are:
- web and application servers during hot redeployment;
-IDE's when runing developped applications (every time U hit Run button in Netbeans or eclipse it loads your application's classes a new);
- etc
this behavior is imporpoer because a heap fills full eventually.
U need to turn on permament heap garbage collection to prevent this error.
I use options
-XX:MaxPermSize=256M
-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled
(stopped my eclipse 3.4 from throwing "java.lang.OutOfMemoryError: PermGen space" so it should also work with netbeans).