Anonymous | Login
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
TypeCategorySeverityReproducibilityDate SubmittedLast Update
defect[Openbravo ERP] A. Platformminorhave not tried2021-08-06 08:502021-09-15 09:25
ReporteralostaleView Statuspublic 
Assigned Toalostale 
PrioritynormalResolutionfixedFixed in VersionPR21Q4
StatusclosedFix in branchFixed in SCM revision
ProjectionnoneETAnoneTarget Version
OSAnyDatabaseAnyJava version
OS VersionDatabase versionAnt version
Product VersionSCM revision 
Review Assigned To
Web browser
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo

0047511: Entity.getProperty generates too much memory garbage

DescriptionProfiling JVM object allocation raises there are many byte[] allocations in Entity.getProperty method.

These allocations come from String concatenation to generate an error message in case the requested property does not exist.

Note even the method is not expensive itself, it is invoked many times resulting in the top object allocator.
Steps To Reproduce1. Start recording with JDK Mission Control's Flight Recorder [1]
2. Ie. in POS create 4 time a ticket with 4 product and pay it
3. Check Flight Recorder results.
  -> It warns about byte[] allocation in Allocated Classes section
  -> In Memory details (see attached no-fix.png) check a total of ~250MB byte[] where allocated, checking the stack traces, it can be seen the main contributor for this allocation is Entity.getProperty.

[1] [^]
Proposed SolutionOptimize messages to be generetad only if required. 2 alternatives:

1. Overload Check.isNotNull to support a message Supplier:
  Check.isNotNull(prop, () -> "Property " + propertyName + " does not exist for entity " + this));

2. Do the check null directly in Entity.getProperty

Even alternative 1 reduces a lot the byte[] allocation, lambdas are allocated. Being a method that is invoked all the time, 2nd alternative is more optimal (although a bit dirtier from the code point of view).

Attached image (fix2.png) of the 2nd alternative executing the same steps as described above.
Attached Filespng file icon no-fix.png [^] (110,330 bytes) 2021-08-06 08:54

png file icon fix2.png [^] (84,359 bytes) 2021-08-06 08:58

- Relationships Relation Graph ] Dependency Graph ]

-  Notes
hgbot (developer)
2021-08-06 09:34

Merge Request created: [^]
hgbot (developer)
2021-09-15 09:25

Directly closing issue as related merge request is already approved.

Repository: [^]
Changeset: 2d8de0958f551e3e17e91019ed70bb05642c754e
Author: Asier Lostalé <>
Date: 2021-09-15T07:47:07+02:00
URL: [^]

fixes ISSUE-47511: Entity.getProperty generates too much memory garbage

Entity.getProperty, which is invoked all the time, generated a huge
amount of memory garbage just preparing the message to be displayed in
case the requested property does not exist, which is thrown only very

It has been optimized by moving the null check from Check.isNotNull to
Entity class and generating the message only when it is actually thrown.

M src/org/openbravo/base/model/
hgbot (developer)
2021-09-15 09:25

Merge request merged: [^]

- Issue History
Date Modified Username Field Change
2021-08-06 08:50 alostale New Issue
2021-08-06 08:50 alostale Assigned To => platform
2021-08-06 08:50 alostale Modules => Core
2021-08-06 08:50 alostale Triggers an Emergency Pack => No
2021-08-06 08:50 alostale Assigned To platform => alostale
2021-08-06 08:50 alostale Tag Attached: Performance
2021-08-06 08:52 alostale Steps to Reproduce Updated View Revisions
2021-08-06 08:54 alostale File Added: no-fix.png
2021-08-06 08:55 alostale Steps to Reproduce Updated View Revisions
2021-08-06 08:57 alostale Proposed Solution updated
2021-08-06 08:58 alostale File Added: fix2.png
2021-08-06 09:34 hgbot Note Added: 0130999
2021-09-15 07:46 alostale Summary Entity.getProperty generates too memory garbage => Entity.getProperty generates too much memory garbage
2021-09-15 09:25 hgbot Resolution open => fixed
2021-09-15 09:25 hgbot Status new => closed
2021-09-15 09:25 hgbot Fixed in Version => PR21Q4
2021-09-15 09:25 hgbot Note Added: 0131800
2021-09-15 09:25 hgbot Note Added: 0131801

Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker