Skip to content

Common mistakes

SilverIce edited this page Sep 3, 2016 · 7 revisions

Dangling object identifiers

Don't release an object without zeroing its identifier, especially if jobjectId is a field in a script (and not some local variable). This leaves dangling object identifier. When the object pointed by jobjectId identifier will be deleted, the identifier (the number itself) may be reused (after some time) for a new object created elsewhere, and jobjectId will point to that new object.

JValue.release(jobjectId)

The sample below is valid. In case jobjectId is a field, it's best to use properties and JValue.releaseAndRetain to encapsulate/hide release & retain operation as shown in Lifetime Management.

jobjectId = JValue.release(jobjectId)

Clone this wiki locally