Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust the max heap memory to the max ram installed #1713

Merged
merged 10 commits into from
Jun 20, 2023

Conversation

patrickdalla
Copy link
Collaborator

Adjust the max heap memory to the max ram installed if the -Xmx parameter is larger than this. Closes #1712

break;
}
long memSize = Math.min(parmSize,((com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean()).getTotalPhysicalMemorySize());
heapArgs.add("-Xmx"+memSize/1024+"K");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think -Xms need to be handled here too, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if we should treat -Xms in the same way. If some user pass this parameter intentionally, he wants to make some performance tunning, and for that he should know the installed memory and tune this parameter accordingly, and if wrongly tuned in a way that leads to OOM or IPED halting, he should "feel" the effect and correct it by himself.

BTW, I will include some code to inform that the change in -Xmx has occured in App LOG.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we could change the -Xmx to half the installed memory only if it is greater than the total memory, so the user have a little "space" to increase by himself this value. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we could change the -Xmx to half the installed memory only if it is greater than the total memory, so the user have a little "space" to increase by himself this value. What do you think?

It seems a good option.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if we should treat -Xms in the same way. If some user pass this parameter intentionally, he wants to make some performance tunning, and for that he should know the installed memory and tune this parameter accordingly, and if wrongly tuned in a way that leads to OOM or IPED halting, he should "feel" the effect and correct it by himself.

The problem is that in line 75 -Xms is already handled, so the current code would transform a -Xms## into a -Xmx##, which I guess is not the desired behavior, right?

About changing or not -Xms, the proposed idea is to change a -Xmx, even if it was passed by the user, if it exceeds the total physical memory, right? Wouldn't the same reasoning apply to -Xms?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes. I didn't noted. I put it there for some testing reason. I will remove.

Copy link
Collaborator Author

@patrickdalla patrickdalla Jun 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About the same reasoning: The best option, I think, would be not to change the user chosen passed value via cmd line and let him evaluate the effects.
But we need to change somewhere the default max heap memory. The "exe" loads with "-Xmx30G", and this value should change. Maybe we could change the code that declares this "-Xmx30G". But I didn't find where is it. @lfcnassif , could we point out where this value of 30G is specified?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "exe" loads with "-Xmx30G", and this value should change. Maybe we could change the code that declares this "-Xmx30G". But I didn't find where is it. @lfcnassif , could we point out where this value of 30G is specified?

It is hard coded into the EXE, I'll remove it and leave it blank (no heap option).

About current changes, my proposal is to use half the physical memory as Xmx if it is not specified by user. If it is specified and if it is greater than physical memory, cut it to be equal to physical memory. Seems reasonable?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put it there for some testing reason. I will remove.

Xms was already there before, it should be passed to the second process if specified by user. And I agree to @tc-wleite, if specified and greater than physical memory, limiting it to physical memory seems reasonable to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And even if Xms/Xmx are specified by user, I think we can limit them to physical memory, allocating more makes no sense to me. That's why I tagged the issue as bug. Like current EXE, users may create and distribute scripts to open multicases and specify fixed heap values which may be bad depending on the runtime machine, so I think limiting to physical memory is a good approach to workaround user mistakes.

@lfcnassif
Copy link
Member

lfcnassif commented Jun 19, 2023

What about using 1/4 the RAM when processing if -Xmx is not specified (current behavior) and limiting to 32GB? We have image reading processes and could have parsing processes running concurrently. 1/2 RAM would be used just at analysis time.

Copy link
Member

@lfcnassif lfcnassif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @patrickdalla for this, and thanks @tc-wleite for reviewing!

@lfcnassif lfcnassif merged commit 7b65a00 into master Jun 20, 2023
@lfcnassif lfcnassif deleted the MaxMemoryBootstrapCorrection branch June 20, 2023 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Max heap memory used by Analysis App can be greater than RAM causing UI crashes
3 participants