Open jliew1975 opened 5 years ago
Would you like to show some code you have or even better create a PR?
Ok will follow up on this. later and create a PR.
Didn't have time to create a pull request but below is the snippet code I have for fixing the memory leak.
// clean up
if (emfResource != null) {
try {
Collection<StateMachine> stateMachines =
EcoreUtil.getObjectsByType(emfResource.getContents(),
UMLPackage.Literals.STATE_MACHINE);
stateMachines.forEach(sm -> sm.destroy());
model.destroy();
emfResource.unload();
} catch (Exception e) {
}
}
Everytime a state machine is build the code create a UmlModelParser and parse the UML to get reference to DataHolder. However, instances of StateMachineImpl within the model are not release or garbage collected when GC kicked in results in memory leak. I have a workaround on this currently where I destroy the instance of UmlModelParser when DataHolder is created which at the end clean up instances of StateMachineImpl within the model. Also to improve performance I have cache the DataHolder for subsequence build of the same UML model using resource filename as the key. Hope you can see the issue and fixed this for others so they don't struggle like I did.