[MGNLUI-4004] Asynchronous actions can consume a lot of memory Created: 02/Sep/16 Updated: 09/Feb/17 Resolved: 15/Sep/16 |
|
| Status: | Closed |
| Project: | Magnolia UI |
| Component/s: | None |
| Affects Version/s: | 5.3.9, 5.4.x |
| Fix Version/s: | 5.3.17, 5.4.10, 5.5 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Philipp Bärfuss | Assignee: | Federico Grilli |
| Resolution: | Fixed | Votes: | 2 |
| Labels: | None | ||
| Remaining Estimate: | 0d | ||
| Time Spent: | 2d 3.5h | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||
| Issue Links: |
|
||||
| Template: |
|
||||
| Acceptance criteria: |
Empty
|
||||
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
||||
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
||||
| Release notes required: |
Yes
|
||||
| Date of First Response: | |||||
| Sprint: | Basel 61 | ||||
| Story Points: | 5 | ||||
| Description |
|
The inner class AbstractCommandAction.CommandActionTriggerListener is not declared static and hence each instance is bound to the parent action object. This action object has references to UI related objects. This way the asynchronous tasks in the scheduler use much more heap than needed which makes the GCs job unnecessary hard. We have seen a system where this added up to 1Gigabite of heap. If I am right then adding the static modifier to the inner class would be enough. |
| Comments |
| Comment by Federico Grilli [ 05/Sep/16 ] |
– Joshua Bloch, Effective Java I know, I'm very fond of this piece of wisdom |
| Comment by Federico Grilli [ 12/Sep/16 ] |
|
From my first investigations and debugging, making the inner listener class static certainly helps to reduce the size of the object in memory (from ~6kB to less than 1kB) as you can see from the attached profiler screenshot. Still those objects apparently won't be freed by GC because they are kept internally by the Quartz scheduler, see UPDATE Before: Each time an activation is launched from the UI, the CommandTriggerListener class is kept in memory even when the job has completed (in this case two activations were started) |
| Comment by Federico Grilli [ 14/Sep/16 ] |
|
Just checked 5.4.x branch which is the same as master or 5.5 in this case. Same issue as in 5.3.x. I would therefore apply the same fix to those branches before the problem shows up in some production environment. |