# Issue : java.lang.OutOfMemoryError: Java heap space

**URL:** <https://forum.xwiki.org/t/issue-java-lang-outofmemoryerror-java-heap-space/15250>\
**Category:** Help / Discuss\
**Tags:** xwiki-1660\
**Created:** [July 31, 2024, 1:07pm UTC](https://forum.xwiki.org/t/issue-java-lang-outofmemoryerror-java-heap-space/15250 "2024-07-31T13:07:36Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmarkoll](https://forum.xwiki.org/letter_avatar_proxy/v4/letter/j/dc4da7/32.png) [@jmarkoll](https://forum.xwiki.org/u/jmarkoll)\
**Post date:** [July 31, 2024, 1:07pm UTC](https://forum.xwiki.org/t/issue-java-lang-outofmemoryerror-java-heap-space/15250/1 "2024-07-31T13:07:36Z")

</div>

Hi,  
I am testing how long importing big spaces from Confluence to XWiki require, (from 3GB up to 12GB or so, at the moment, 6 to 9Gigabytes).

The Server is Debian 11 with XWiki 16.6.0, with **xwiki-jetty** and **xwiki-postgresql**. Java is openjdk-17-jre-headless (17.0.11+9-1~deb11u1). This is a VM with over 50GB space available and 32GB RAM.

I imported a pair of spaces and with the first space, before starting with _Nested Pages Migration_ I stumbled for the first time upon this message:

```auto
Current conversion (Page URL)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Failed to execute the \[velocity\] macro. Cause: \[Java heap space\]. Click on this message for details.

java.lang.OutOfMemoryError: Java heap space

```

then I noticed in the /var/lib/xwiki/data a file having for name `java_pid3489.hprof`, size 1.4GB.

Unsure about what to do with it, I just moved it to the /home/user (keeping ownership and rights/permissions) and reloaded the page, the message was gone.

However while next space is about to finish importation with the Nested Pages Migration stage, I get the same message again.  
I tried to ignore it, but the first step of Nested Pages Migration would not finish loading the space.

I would very much like an advice. How can I fix it?

---

<div class="post-metadata">

**Author:** ![tmortagne](https://forum.xwiki.org/user_avatar/forum.xwiki.org/tmortagne/32/4930_2.png) [@tmortagne](https://forum.xwiki.org/u/tmortagne)\
**Post date:** [July 31, 2024, 1:40pm UTC](https://forum.xwiki.org/t/issue-java-lang-outofmemoryerror-java-heap-space/15250/2 "2024-07-31T13:40:26Z")

</div>

> [@jmarkoll](#):
>
> then I noticed in the /var/lib/xwiki/data a file having for name `java_pid3489.hprof`, size 1.4GB.

That file is a dump of the memory, that’s generally the best way to debug why there is an OutOfMemoryError (but it contains the whole memory of your instance, so it might include sensitive information). The stack trace associated with the very first OutOfMemoryError you can find in your log can sometimes give a clue of what is the cause (but honesty, it could as well be a consequence).

AFAIK the Confluence import itself is not supposed to take much RAM, but maybe something else is impacted by the number of pages you are adding to this instance.

> [@jmarkoll](#):
>
> _Nested Pages Migration_

My understanding is that the Nested Pages Migration is not needed at all anymore.

I guess you could try to allocate a bit more memory to see if it’s better. You can take a look at [xwiki-docker/README.md at master · xwiki/xwiki-docker · GitHub](https://github.com/xwiki/xwiki-docker/blob/master/README.md#passing-jvm-options) for how to pass Java command line parameters and [https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Performances/#HMemory](https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Performances/#HMemory) for some clue of which values to try.

> [@jmarkoll](#):
>
> I tried to ignore it, but the first step of Nested Pages Migration would not finish loading the space.

Once you get an OutOfMemoryError pretty much anything can be broken for good, and you generally cannot really trust an instance anymore, the safest is generally to restart.

---

<div class="post-metadata">

**Author:** ![jmarkoll](https://forum.xwiki.org/letter_avatar_proxy/v4/letter/j/dc4da7/32.png) [@jmarkoll](https://forum.xwiki.org/u/jmarkoll)\
**Post date:** [July 31, 2024, 1:59pm UTC](https://forum.xwiki.org/t/issue-java-lang-outofmemoryerror-java-heap-space/15250/3 "2024-07-31T13:59:22Z")

</div>

> [@tmortagne](#):
>
> My understanding is that the Nested Pages Migration is not needed at all anymore.

Is that so? Does it mean Confluence XML would do the whole job? Since which XWiki versions it is not needed anymore?

---

<div class="post-metadata">

**Author:** ![tmortagne](https://forum.xwiki.org/user_avatar/forum.xwiki.org/tmortagne/32/4930_2.png) [@tmortagne](https://forum.xwiki.org/u/tmortagne)\
**Post date:** [July 31, 2024, 2:02pm UTC](https://forum.xwiki.org/t/issue-java-lang-outofmemoryerror-java-heap-space/15250/4 "2024-07-31T14:02:07Z")

</div>

> [@jmarkoll](#):
>
> Does it mean Confluence XML would do the whole job?

Yes.

> [@jmarkoll](#):
>
> Since which XWiki versions it is not needed anymore?

Not much to do with the XWiki version. The support was made optional in the Confluence extension version 9.35.0 and made the default behavior in 9.46.0 from what I see in the changelog.

---

<div class="post-metadata">

**Author:** ![jmarkoll](https://forum.xwiki.org/letter_avatar_proxy/v4/letter/j/dc4da7/32.png) [@jmarkoll](https://forum.xwiki.org/u/jmarkoll)\
**Post date:** [July 31, 2024, 2:07pm UTC](https://forum.xwiki.org/t/issue-java-lang-outofmemoryerror-java-heap-space/15250/5 "2024-07-31T14:07:55Z")

</div>

This is wonderful news, thank you! This might indeed save time.

(About the memory matter, I have been instructed to use the /etc/environment file, as per the examples listed in the file `/usr/lib/xwiki-jetty/start_xwiki.sh`).

---

<div class="post-metadata">

**Author:** ![tmortagne](https://forum.xwiki.org/user_avatar/forum.xwiki.org/tmortagne/32/4930_2.png) [@tmortagne](https://forum.xwiki.org/u/tmortagne)\
**Post date:** [July 31, 2024, 2:10pm UTC](https://forum.xwiki.org/t/issue-java-lang-outofmemoryerror-java-heap-space/15250/6 "2024-07-31T14:10:20Z")

</div>

> [@jmarkoll](#):
>
> (About the memory matter, I have been instructed to use the /etc/environment file, as per the examples listed in the file `/usr/lib/xwiki-jetty/start_xwiki.sh`).

I thought you were using the docker image, actually. Did you mean you used the Debian package `xwiki-xjetty-pgsql` (there is no package named **xwiki-jetty** and **xwiki-postgresql** ) ?

---

<div class="post-metadata">

**Author:** ![jmarkoll](https://forum.xwiki.org/letter_avatar_proxy/v4/letter/j/dc4da7/32.png) [@jmarkoll](https://forum.xwiki.org/u/jmarkoll)\
**Post date:** [July 31, 2024, 2:16pm UTC](https://forum.xwiki.org/t/issue-java-lang-outofmemoryerror-java-heap-space/15250/7 "2024-07-31T14:16:40Z")

</div>

> [@tmortagne](#):
>
> `xwiki-xjetty-pgsql`

Yes! And `xwiki-xjetty-common`

---

<div class="post-metadata">

**Author:** ![jmarkoll](https://forum.xwiki.org/letter_avatar_proxy/v4/letter/j/dc4da7/32.png) [@jmarkoll](https://forum.xwiki.org/u/jmarkoll)\
**Post date:** [August 1, 2024, 8:27am UTC](https://forum.xwiki.org/t/issue-java-lang-outofmemoryerror-java-heap-space/15250/8 "2024-08-01T08:27:08Z")

</div>

Hello @tmortagne if _Nested Pages Migration_ isn’t needed at all anymore, can I safely assume it is safe to be removed?

---

<div class="post-metadata">

**Author:** ![tmortagne](https://forum.xwiki.org/user_avatar/forum.xwiki.org/tmortagne/32/4930_2.png) [@tmortagne](https://forum.xwiki.org/u/tmortagne)\
**Post date:** [August 1, 2024, 8:47am UTC](https://forum.xwiki.org/t/issue-java-lang-outofmemoryerror-java-heap-space/15250/9 "2024-08-01T08:47:08Z")

</div>

> [@jmarkoll](#):
>
> if _Nested Pages Migration_ isn’t needed at all anymore, can I safely assume it is safe to be removed?

Yes (even before, it was only needed while doing the migration, but then it became useless).

---

<div class="post-metadata">

**Author:** ![jmarkoll](https://forum.xwiki.org/letter_avatar_proxy/v4/letter/j/dc4da7/32.png) [@jmarkoll](https://forum.xwiki.org/u/jmarkoll)\
**Post date:** [August 1, 2024, 9:07am UTC](https://forum.xwiki.org/t/issue-java-lang-outofmemoryerror-java-heap-space/15250/10 "2024-08-01T09:07:37Z")

</div>

Thank you very much!
