Reputation: 5952
I am creating locks, but names for locks are dynamic. There can be many messages for a given businessCaseId and therefore, many locks will be created.
lock = lockFactory.createLock(vars.businessCaseId)
lock.lock()
try{
//business function implementation for the given businessCaseId
Can I know please what will happen to the lock object after lock.unlock()
? (Yes, the lock is released) Is it removed from the memory/eligible for GC Or stayed on memory Or what? Should I set to null ? lock = null
?
I referred following document, but no much info. https://docs.mulesoft.com/mule-runtime/4.4/distributed-locking
Upvotes: 0
Views: 345
Reputation: 25664
Setting Java variable to null to indicate garbage collection usually is useless. If there are other references it is not going to be garbage collected. If there are not other references, why bother? If there are other references, it is useless. This is a common question in Java, unrelated to any Mule features. It has been asked in Stackoverflow in the past. I'll make this answer about the Mule specific topics instead.
I'm this particular case, it is up to the implementation if unlock actually released the object or not after unlock. Evidently there is a collection somewhere. Otherwise using name to identify locks across threads would not work.
Since it is not documented, I would not be concerned until you observe an actual issue associated with it. For example, memory increases that in a heap dump can be associated with Mule locks.
Upvotes: 1