Reputation: 697
Below, You see a part of Application Programming Notes Java Card 3 Platform Classic Edition about object deletion management :
void updateBuffer(byte requiredSize)
{
try
{
if(buffer != null && buffer.length == requiredSize)
{
//we already have a buffer of required size
return;
}
JCSystem.beginTransaction();
byte[] oldBuffer = buffer;
buffer = new byte[requiredSize];
if (oldBuffer != null)
JCSystem.requestObjectDeletion();
JCSystem.commitTransaction();
}
catch(Exception e)
{
JCSystem.abortTransaction();
}
}
The question is :
When I call JCSystem.requestObjectDeletion();
in the if
expression, How it recognize which one the buffer or oldBuffer object must be delete?
Upvotes: 0
Views: 209
Reputation: 93948
Object deletion is typically performed during start up. So basically the system can sweep the memory just like a normal Java Garbage Collector at that time.
If no references are found to a specific object, then the space occupied by that object can be collected. As the oldBuffer
reference is out of scope by that time there will be no reference to the old array left. The exact memory management is implementation dependent.
Upvotes: 2