Page 1 of 1

How to free heap memory on wiki page rendering?

Posted: Fri Apr 26, 2013 11:53 am
by JoernTietjen
Hi all,

in a wiki page I use a complex macro which is processed for every item in a set of workitems selected by a query.
If the set is small everything works out fine.
However, if the set is rather large I get errors on the server side like:

java.lang.OutOfMemoryError : Java heap space

Page rendering never finishes in this case and even the Polarion server process might be affected.
I suppose that garbage collection is performed after all content of the wiki page is processed and rendered.
Each invocation of the macro is independent of the others so there's no need to store intermediate data.
I'm curious to know if there is a way to explicitly free heap memory after each macro call by running the garbage collector.
Would a simple delay of macro execution after each iteration do the trick because it then lets kick in the asynchronous process of garbage collection?

Any hints or pointers are appreciated.


Re: How to free heap memory on wiki page rendering?

Posted: Tue Apr 30, 2013 5:32 pm
by Zwi_B&R
Ah, this could explain why we are facing serious performance issues which force us to restart our polarion server like every week.
We are also doing some wiki macro stuff over workitem lists. And often page rendering never finishes.

But we don't know what to do about it.
I have a feeling that problems like this began after update from Polarion 2010 to 2011, but I'm not sure.

Re: How to free heap memory on wiki page rendering?

Posted: Thu May 02, 2013 6:46 am
by JoernTietjen
Apart from instant resource management issues I would recommend to reboot your Polarion server cyclically in order to avoid memory leaks etc.
Also, trouble with cached macro name resolution will be minimized.
At our site we perform a server reboot every night after the backup process has finished (which might be overkill, but anyhow ...).

Re: How to free heap memory on wiki page rendering?

Posted: Mon May 06, 2013 2:10 pm
by hanzlikovam
Hello gentlemen,

To avoid the java.lang.OutOfMemoryError : Java heap space issue I would like to recommend you to increase the -Xmx parameter.
For Linux edit the file /opt/polarion/etc/ and these default settings:

export PSVN_JServer_opt="-server

For Windows: C:\Polarion\polarion\polarion.ini and these default settings:


The value -Xmx means maximum java heap space. You can increase it to value bigger than 1500m on 64-bit systems.
The parameter -Xms is initial heap size (memory allocated immediately after JVM start) .

Take care, the system needs some memory for itself and JVM has some overhead too. For 4 GB physical RAM is appropriate value -Xmx2048m, for 8GB physical RAM -Xmx4096m. It is necessary to monitor and avoid the swapping.

After change the file with Java settings, restart of Polarion is required and in case of Windows reinstall of the service is also required.

If you have more questions related to this issue please contact Support Team directly at

Best regards
Martina Hanzlikova
Polarion Support Team

Re: How to free heap memory on wiki page rendering?

Posted: Thu Jun 23, 2016 7:41 am
by matthiaw
Yesterday i programmed a Script which uses a lot of Velocity-Variables and in the evening we got the message running out of heap space. I not found it helpfull to increase the memory or restart the server, so i looked into the API. There i found

Code: Select all

Max: $xwiki.getXWiki().maxMemory()
Total: $xwiki.getXWiki().totalMemory()
Free: $xwiki.getXWiki().freeMemory()

## When i unmark one of the three lines i see an impact on the "freeMemory"
## $xwiki.getXWiki().flushCache()
## $xwiki.getXWiki().gc()
## $xwiki.clearPagesCache()

I did not know if this helps continuously, but i give it a try from time to time.


Re: How to free heap memory on wiki page rendering?

Posted: Wed May 10, 2017 5:56 am
by tomicrow
Java Memory Management

There is no manual way of doing garbage collection in Java.

Java Heap is divided into three generation for the sake of garbage collection. These are the young generation, tenured or old generation, and Perm area.

New objects are created in the young generation and subsequently moved to the old generation.

String pool is created in Perm area of Heap, Garbage collection can occur in perm space but depends on upon JVM to JVM.

Minor garbage collection is used to move an object from Eden space to Survivor 1 and Survivor 2 space, and Major collection is used to move an object from young to tenured generation.

Whenever Major garbage collection occurs application, threads stops during that period which will reduce application’s performance and throughput.

More about...Java Memory Management