2

I have a point of sale application developed in JavaFX. Some clients have pointed that the system starts to hang in a specific time of the day, when it's used more often.

I did some tests limiting the max heap memory of my app to a very small amount (-Xmx30m) and i did notice system hangings, some slow operations that usually would take less than a second, windows that open just with a white background with no content, etc... So i thought that could be the problem on my client too.

So i thought that on these clients where i am getting these errors, maybe the maximum memory used is by default somehow lower than it should be, and by adding the argument to specify maximum memory and starting memory through -Xmx1512m and -Xms1512m maybe that could fix the problem, but is it a good practice to do so? Can i have unwanted side effects?

1
  • You shouldn't increase the maximum heap to more than about 90% of the free memory. Commented Jan 13, 2016 at 12:19

2 Answers 2

4

If your application needs 1.5gb of memory then that's the way to solve your issue. But if the problem is due to a "memory leak" in your program, changing the settings may only hide the source of the problem.

You should probably try to profile the memory usage of your application to verify that:

  • the slowness is due to memory usage and
  • the memory usage is "normal", i.e. it is not due to a programming design problem, by identifying what is using the memory.

For example, I had a JavaFX application that was memory hungry and realised that a lot of memory was used by JavaFX properties objects that couldn't get garbage collected because the JavaFX objects (tables etc.) were keeping references to those properties. I changed the design to reuse existing properties vs. creating new ones and the memory problem got solved.

Sign up to request clarification or add additional context in comments.

5 Comments

Sorry but what JavaFX properties objects are you talking about?
@MateusViccari A lot of SimpleDoublePropertys in my case.
@MateusViccari Which version of JavaFX you are using? We faced memory leaks with JavaFX 2.2(it may be version before this) because of bug in StyleHelper. Moving to JavaFX 8 fixed that.
I am using JavaFX 8, in the the latest version of JRE
@assylias can you give example on how to reuse existing properties in javafx?
1

Heap size should be determined on your system's memory needed. -Xmx1512m and -Xms1512m will have no problem you the machine having enough memory like 4GB or more. And it is not bad practice though the option given to you for tuning your application. The only side effect you may face whenever GC called then it will take very little longer than before but i think it can't be noticed.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.