Page 1 of 1

javacard applet develop question- profile decode

Posted: Wed Mar 15, 2017 4:00 am
by z535539710
1. Why it is recommended to create all new objects at applet installation time in javacard?
2. Since my javacard applet is designed to decode profiles encoded in TLV structure using DER encoding,I have to new objects dynamically during the decoding process. how can I release the objects when the decoding process finished, or is there a better way to realize this? :)

Re: javacard applet develop question- profile decode

Posted: Wed Mar 15, 2017 6:41 am
by UNKNwYSHSA
1 To check if the memory space is enough, required algorithm is supported, or ..., before you run applet commands.
2 Call api JCSystem.requestObjectDeletion() at the end of the command, unreferenced objects will be reclaimed before next APDU processing, and use api JCSystem.isObjectDeletionSupported() to check if the function is supported by the JCVM.

Re: javacard applet develop question- profile decode

Posted: Wed Mar 15, 2017 9:32 pm
by z535539710
UNKNwYSHSA wrote:1 To check if the memory space is enough, required algorithm is supported, or ..., before you run applet commands.
2 Call api JCSystem.requestObjectDeletion() at the end of the command, unreferenced objects will be reclaimed before next APDU processing, and use api JCSystem.isObjectDeletionSupported() to check if the function is supported by the JCVM.


Thanks very much for your answer, and I have another question:

if my card support GC, then will the JCSystem.requestObjectDeletion bring additional performance consumption? How to estimate the influence?

Thanks again and expecting your answer

Re: javacard applet develop question- profile decode

Posted: Wed Mar 15, 2017 10:15 pm
by UNKNwYSHSA
From JC API:
This method is invoked by the applet to trigger the object deletion service of the Java Card runtime environment. If the Java Card runtime environment implements the object deletion mechanism, the request is merely logged at this time. The Java Card runtime environment must schedule the object deletion service prior to the next invocation of the Applet.process() method.


The GC process influence the next APDU process, not the APDU contains JCSystem.requestObjectDeletion().
If you take care of the next APDU. The only way is optimize your code, produce fewer template objects when command processing.
Notice: Both the new operation and GC take effect on performance.

Re: javacard applet develop question- profile decode

Posted: Wed Mar 15, 2017 10:38 pm
by z535539710
thanks very much for your suggestion :D

Re: javacard applet develop question- profile decode

Posted: Thu Mar 16, 2017 4:12 am
by UNKNwYSHSA
:D