Page 2 of 2

Re: zmmailbox : Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

Posted: Tue Jun 10, 2025 2:10 pm
by Leeloo
Hello,


Thank you for your feedback ;)


Does this curl command do what zmmailbox does in the end?
Does it produce the same archive?

I asked support if other people had reported the same behaviour with zmmailbox, but they didn't reply on this point, but it seems to be the case.

What distribution do you use?
And what's the main reason why you're sticking with zmmailbox? Just asking for information.


Thanks

Re: zmmailbox : Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

Posted: Tue Jun 10, 2025 5:45 pm
by teyxwhat
As far as I know it gives the same output as running the export in the GUI.

tried importing the export file, the folders and message counts are intact. Good enough for our purposes.

We started seeing the issue when we upgraded to Release 10.1.8.GA.4655.UBUNTU22_64 NETWORK edition from 10.0.14 Ubuntu 20

We use it to make a copy of an account before deleting.
If there's a better way, please let me know.

Re: zmmailbox : Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

Posted: Thu Jun 26, 2025 7:45 am
by Leeloo
Hello,

Thank you for your reply.

How do you import the account (the mailbox export data), also with CURL?

Thank you.

Re: zmmailbox : Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

Posted: Sat Jun 28, 2025 11:09 am
by MarkDavis
This error usually means the Java process doesn’t have enough memory allocated. You can resolve it by increasing the heap size using flags like -Xmx2g (for 2GB) when running the zmmailbox command. Make sure your system has enough available RAM.

Re: zmmailbox : Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

Posted: Mon Jun 30, 2025 1:21 pm
by Copyright
Had the same issue. Solve it by incrasing Xmx in zmlocalconfig zimbra_zmjava_options

You can check the Xmx:
su - zimbra -c 'zmlocalconfig zimbra_zmjava_options'

And incrase it:
su - zimbra -c 'zmlocalconfig -e zimbra_zmjava_options="-Xmx1024m <other_options>"'

Re: zmmailbox : Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

Posted: Mon Jun 30, 2025 1:23 pm
by Klug

Re: zmmailbox : Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

Posted: Tue Jul 01, 2025 2:40 pm
by akanellis
After upgrading to 10.1.7 FOSS I have also noticed that the automated backups on my servers don't work anymore for all accounts. I was also using zmmailbox to do the actual backup.

I have tried changing -Xmx to 2G (the default value was 256m) and it didn't help. I'm not increasing it more even though most of the servers have 16+ GB of ram because it's eating the ram like it's gasoline on a Bugatti Veyron. Some accounts were backed up but some large ones (100+ GB size) returned 0 bytes size.

The only thing that worked was the curl method and I have updated all my backup scripts to use this instead.
Leeloo wrote: Thu Jun 26, 2025 7:45 am How do you import the account (the mailbox export data), also with CURL?
You can use this method: https://wiki.zimbra.com/wiki/Import_mai ... using_curl

Re: zmmailbox : Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

Posted: Mon Aug 11, 2025 11:05 am
by mocha
In case you’re wondering, the official support answer is:

“Zimbra doesn’t support export-import of large mailboxes in TGZ because of broken TGZ files and other I/O errors.”

and they recommend using CURL instead. Apparently, a 1 GB mailbox counts as “large” now. :lol:

Solution for java.util.Arrays.copyOf / OutOfMemoryError during mailbox backup (Zimbra 10.0.18)

Posted: Thu Feb 19, 2026 3:41 pm
by Orion2K
Hello,

After upgrading to Zimbra OSS 10.0.18, our individual mailbox backup scripts (using zmmailbox) stopped working and started generating the following Java heap space error:

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.base/java.util.Arrays.copyOf(Arrays.java:3537)
at java.base/java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:100)
at java.base/java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:130)
at com.zimbra.client.ZMailbox.getResource(ZMailbox.java:3502)
at com.zimbra.client.ZMailbox.getRESTResource(ZMailbox.java:3625)
at com.zimbra.client.ZMailbox.getRESTResource(ZMailbox.java:3587)
at com.zimbra.cs.zclient.ZMailboxUtil.doGetRestURL(ZMailboxUtil.java:3025)
at com.zimbra.cs.zclient.ZMailboxUtil.execute(ZMailboxUtil.java:1220)
at com.zimbra.cs.zclient.ZMailboxUtil.main(ZMailboxUtil.java:2917)

To resolve this, we have refactored our backup scripts to use Curl via the REST API instead of the native zmmailbox command. This bypasses the Java heap limits of the client utility.

If you are facing the same issue, you can use the following commands to get your backups working again:

1. Working EXPORT command:

curl -v -k -u admin@DOMAIN.fr:PASSWORD 'https://webmail.DOMAIN.fr:7071/home/tes ... r/?fmt=tgz' -o /tmp/test_mailbox.tgz

2. Working IMPORT command:

curl -v -k -u admin@DOMAIN.fr:PASSWORD --data-binary "@/mnt/backup/test_mailbox.tgz" "https://webmail.DOMAIN.fr:7071/home/res ... solve=skip"

Using this method should prevent any "OutOfMemory" errors as it streams the data directly.

Enjoy!

Re: Solution for java.util.Arrays.copyOf / OutOfMemoryError during mailbox backup (Zimbra 10.0.18)

Posted: Mon Feb 23, 2026 4:57 pm
by adrian.gibanel.btactic
Orion2K wrote: Thu Feb 19, 2026 3:41 pm Hello,

After upgrading to Zimbra OSS 10.0.18, our individual mailbox backup scripts (using zmmailbox) stopped working and started generating the following Java heap space error:
From which older Zimbra version did you update?

We might be able to pin-point a commit that forces everyone to use curl instead of the regular commands because this worked as expected in the past.