How to free heap memory on wiki page rendering?

Description
JoernTietjen
Posts: 36
Joined: Tue Jan 10, 2012 2:08 pm
Location: nr Hamburg, Germany

How to free heap memory on wiki page rendering?

Postby JoernTietjen » Fri Apr 26, 2013 11:53 am

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.

Regards
Joern

Zwi_B&R
Posts: 12
Joined: Fri Nov 19, 2010 9:35 am
Location: Austria
Contact:

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

Postby Zwi_B&R » Tue Apr 30, 2013 5:32 pm

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.

JoernTietjen
Posts: 36
Joined: Tue Jan 10, 2012 2:08 pm
Location: nr Hamburg, Germany

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

Postby JoernTietjen » Thu May 02, 2013 6:46 am

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 ...).

hanzlikovam
Posts: 11
Joined: Thu Nov 15, 2012 8:49 am

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

Postby hanzlikovam » Mon May 06, 2013 2:10 pm

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/config.sh and these default settings:

export PSVN_JServer_opt="-server
-Xms256m
-Xmx600m
-XX:PermSize=128m
-XX:MaxPermSize=128m

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

C:\Polarion\bundled\java\bin\java.exe
-vmargs
-Xms256m
-Xmx640m

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 support@polarion.com


Best regards
Martina Hanzlikova
Polarion Support Team

matthiaw
Posts: 4
Joined: Thu Apr 25, 2013 11:17 am

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

Postby matthiaw » Thu Jun 23, 2016 7:41 am

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.

Regards,
Matthias

tomicrow
Posts: 1
Joined: Wed May 10, 2017 5:53 am

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

Postby tomicrow » Wed May 10, 2017 5:56 am

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

Crow


Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: No registered users and 12 guests