Do we have to delete non-persistent objects ?

0
Hi there Simple question : do we have to delete non-persistent objects ? I thought they would be garbage collected automatically, but  I saw that sometimes microflows in some Mendix modules do delete non persistent entities… What is the best practice ?
asked
3 answers
3

Hi Francois,

As a best practice I think it will be good to delete them. Have a read in documentation for more details especially 2.1 Influencing the Impact on Response Size

 

Hope this helps!

answered
1

Non-persistent objects are garbage collected whenever they are no longer needed / referenced from pages or other objects. So, in most cases you do not need to delete them manually, one exception to this is the non-persistent objects associated with $currentSession. Since $currentSession is a long-living object, it prevents all associated non-persistent objects from getting garbage collected.

There’s an in-depth blog post about garbage collection: https://www.mendix.com/blog/the-art-of-state-part-2-garbage-collection/

answered
0

In my opinion, there is no need to delete non-persistent objects unless you (as the developer) need to delete them while a microflow is executing (i.e. if you are using non-persistent objects during the execution of a microflow and need to manage which objects exist and which don’t).  

answered