archi: jArchi renderViewAsBase64 throws OutOfMemoryError (Java 11.0.5 doesn't allocate heap)

Version of Archi

Archi-Win64-4.7.0-beta1

Archi Plug-ins

jArchi plugin version 0.7.2.20200228

Operating System

Windows 10

Steps to Reproduce the Behaviour

Rendering a .png image with a scale of 2 or larger throws a

java.lang.OutOfMemoryError: Java heap space.

This happens with the new Archi 4.7.0 beta1 version, no problem with the 4.6 version

  1. Select a view with quite a lot of visual elements (a small view with 10 or less elements just worked)
  2. Run this script
view = selection.filter("archimate-diagram-model").first();
try {

	if (!view) {
		window.alert("Please select a view");
	} else {
		console.log("View is: " + view.name);
		let filename = view.name
		let file = window.promptSaveFile({
			title: "Save to file",
			fileName: filename
		});
		let fileExtension = "PNG"

		for (let scale = 1; scale < 5; scale++) {

			var bytes = $.model.renderViewAsBase64(view, fileExtension, {
				scale: scale,
				margin: scale * 10
			});
			fileWithScale = file + "_" + scale + "." + fileExtension
			console.log("Saved to: " + fileWithScale);
			$.fs.writeFile(fileWithScale, bytes, "BASE64");
		}

	}
}
catch (error) {
	console.log(`${typeof error.stack == 'undefined' ? error : error.stack}`);
}
  1. The error occurs in the call $.model.renderViewAsBase64.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 41 (38 by maintainers)

Most upvoted comments

So OCD can be a good thing. And also kudos to JB of course!

Phil, I am impressed how thoroughly you research this issue. Gives me some insight into why Archi is reliable and stable. Kudos to you!

This comment is interesting:

https://github.com/AdoptOpenJDK/openjdk-support/issues/35#issuecomment-561659760

I tested this and that is the issue.

Add these lines to Archi.ini and it solves the problem:

-vm
jre/bin/server

Or delete the jre/bin/client folder to achieve the same thing.