Recommended Max Heap/Stack for CATIA Magic (Cameo/MagicDraw)

 

Recommended Memory settings (Daniel's opinion)

An important setting is the maximum heap space used by the tool.  I recommend  the following:

  • Max Heap of 3000MB
  • Thread Stack Size can be a max of 4096, but the default works for most users.

These are Daniel's settings, and they can work for most users. However, you may not fall into that category. 

Where to change memory settings

First, the memory can be set during installation. But can also be set in the Environment dialog.  

 

 

 

Other Settings

There are also a couple of helpful settings to get low memory warnings and see the memory monitor:

  • Show Memory Monitor - shows the current, high-water mark, and max heap. Also has menu for memory debugging and force for garbage collection.
  • Notify about Low Memory - On by default, this pops up a dialog when heap is almost full. 

 

Memory Settings in the Properties File

If your tool fails to launch due to memory, it is possible to change the startup properties in the /bin/.properties For example, for example with Cameo Enterprise Architect, the name is cameoea.properties. The max heap is the -Xmxx6000 and the Thread Stack size is -Xss4096 in the example below:

 

Understanding Memory Usage

Let's look at how the tool behaves (in general, your milage may vary):

  1. Version 24x (OMG should use 2022x), with a few plugins loaded, including UAF is at about 440mb. 
  2. After load of the UAF sample (found in the samples directory), the memory after a little settling is about 725mb which grows to 1200mb as it does validation and other post-load tasks. After garbage collection 580mb
  3. The current used memory bounces up and down for various tasks, but you can force a garbage collection to reclaim any free memory to see what is currently being used at the time you press the garbage collection (note that memory monitor is enabled and right-cl
  4. ick in the memory monitor to get the Run Garbage Collector). The following shows the right-click menu available in the memory monitor:

  5. The memory monitor shows three numbers: current memory in use, high-water mark (peak memory allocated), and max available. My installation's minimum high-water mark is 1100 MB to 1600 MB, depending on the config and plugins loaded.
  6. The largest model I have is 30,000kb with the UAF sample loaded, the high water mark never went above 1520 and used memory bounces between 700 and 1200. In other words, 2000mb is sufficient unless you are loading a crazy large model or some expensive analysis or simulation.

Given this behavior, conservatively I’d recommend a max heap as low as 3000mb and as high as 6000mb (6000mb is what I have mine set to because I end up with very large models from customers). Enter 3000 in the max heap in environment options or in the properties file.

 -Xmx3000M  

This should be a pretty good number for most users. However,  when creating complex simulations, advanced queries or opening many projects, you may need to go higher. Use the memory monitor which also warns when you are running low on memory.

 

 Java and the Heap/stack (I apologize in advance for the geek speak):

 Java Heap  is a very fungible setting. Heap is just the maximum, not the actual memory allocated. So, a high heap does not instantly gobble up memory. A large max heap does add a little more memory than a smaller heap, but there is not much of a difference we could see.  Simply the heap is a way to stop the application from taking over your computer as memory use grows. Having a large heap allows Java to optimize garbage collection (cleaning up memory) by delaying the freeing of memory. Low heaps can force Java to stop executing the application while it tries to find and free memory. A small max heap can cause a performance issue and could starve the application of working memory. So, low heap bad, high heap is usually ok. The only time that a high heap is bad is for memory leaks or inefficient/buggy software.

Heap generally  depends on free wired memory (the memory chips). We recommend a max  to be half of the wired memory. This ensures there is enough to run other applications. It is not a guarantee, just a rule of thumb, especially when we are sharing the CPU and memory with other applications. 

If the used heap (basically the high water mark, not max heap) is greater than wired memory,  that's when the tool performance starts to degrade. The speed of your swap disk is also critical to that performance. If you have 32 gig of wired memory, a Java application would be screaming fast at  3gb (assuming Word or PPT is open) because the model is 100% in the wired memory. With 32gb of memory on my developer-class laptop and a fast SSD, I can set max heap to 16gb. As said, I don’t recommend maxing it out unless it is absolutely necessary as using swap disk, even with SSD can really slow down the application and even affect other software on your machine.

 

A few more things to keep in mind:

  • As the heap use reaches the max size, the garbage collector is run more often. It is very efficient nowadays, but it can slow things down when the computer has other tasks (bad websites eating CPU/memory, Word/Excel/PPT).
  • A larger heap allows memory-intensive operations to run with fewer interruptions by garbage collection. 
  • The operating system also needs to use a swap disk when the heap used is larger than wired memory. Swapping can slow both the heap and applications as it is used.
  • Any other software (browser, Word, PPT, Excel) can also affect the available wired memory by pushing our tool out of main memory and into swap disk space. In other words, tuning the max heap won’t matter if you have 50 browser tabs open and a dozen applications running.
  • When using Teamwork Cloud, additional disk-based caches and memory operations can cause high Heap and CPU usage. When working with large projects and merging a lot, I shut down the tool every day and reboot often to keep memory from fragmenting.

 

Thread Stack

Thread stack can be important for recursive operations for the query dialog or reporting. It is basically the amount of memory used for each process. Generally, this number is kept low for multi-threaded applications. However, this tool does not have a lot of threads running at the same time. Because of the need to maintain the data integrity of the model, most core operations are running in a single thread.

I only set a large stack when doing complex velocity reports that use recursive macros.

Best Practices

  • Restart the tool most days after loading large models  
  • The max heap may also need to be increased when doing model merge operations or checking model differences with Teamwork Cloud or the Merge plugin.
  • Restart your computer every day or at least once a week 
  • Use the memory monitor to monitor heap usage and increase/decrease heap