The set limit of 1,000 object references was reached while trying to calculate the size of the object graph

I have a jhipster project and I added some objects.
My services are very slow because this is a warning message:

When trying to calculate the size of the graph of objects, the set limit of 1000 instances of objects was reached. Continuing the calibration operation can result in severe performance degradation. This can be avoided by setting the CacheManger or Cache <sizeOfPolicy> maxDepthExceededBehavior elements to "cancel" or add breakpoints with @IgnoreSizeOf annotations. If performance degradation is NOT a problem at the configured limit, raise the limit using the maxDepth attribute of CacheManager or Cache <sizeOfPolicy>. See the Ehcache configuration documentation for more information.

What can I change to increase this limit or cancel the cache in my project?

+6
source share
2 answers

You can add the following tag to resources / ehcache.xml . the maxDepthExceededBehavior = abort property avoids slowing down your services. You can also change maxDepth to increase the limit.

<sizeOfPolicy maxDepth="1000" maxDepthExceededBehavior="abort" /> 
+3
source

Here is what the Ehcache Official Documentation says about calibrating cached records:

Calibrate Cached Records

Items cached with a limited amount of memory will have their measured memory sizes. The entire Element instance added to the cache is measured, including the key and value, as well as the amount of memory to add this instance for internal data structures. Key and value measurement as graphic objects - each link is executed, and the link object is also measured. This happens recursively.

Shared links will be measured by each class that references it. This will lead to overstatement. Shared links should therefore be ignored.

Configuration to limit the schedule of the moved object

Calibrating caches involves moving graphs of objects, a process that may be limited to annotations. This process can also be controlled both at the CacheManager level and on the cache.

Control how much the size of the engine can move when configuring heap elements by adding the next element at the CacheManager level.

 <sizeOfPolicy maxDepth="100" maxDepthExceededBehavior="abort" /> 

This item has the following attributes:

  • maxDepth , which controls how many related objects can be visited before the size of the engine takes any action. This attribute is required .

  • maxDepthExceededBehavior , which indicates what happens when the maximum depth is exceeded when determining the size of the object. Possible values ​​for this application:

    • continue , which forces the size of the engine to register a warning and continue the calibration operation. If this attribute is not specified, continue is the behavior used.

    • abort , which causes the size of the engine to cancel calibration, logging warnings, and flagging the cache as improperly tracking memory usage This setting returns Ehcache.hasAbortedSizeOf() true

The SizeOf policy can be configured at the cache manager level (directly under <ehcache> ) and at the cache level (under <cache> or <defaultCache> ). A cache policy always overrides cache manager one, if both are installed. This element does not affect distributed caches.

+1
source

All Articles