Question

What is the maximum size when defining a byte array in java card?

In my 32k java card, I defined a byte array with length of (9*1024) and I got 6A 84 error (Not enough memory space in the file), Also when I define it with length of (8*1024) there is no error.

Was it helpful?

Solution

That depends on where you allocate the array (persistent memory, transient memory) and on the available memory on your specific card. The technical limit for an array's size in Java Card is 32767 elements, because array indices are of type short and can only be non-negative values.

You can get an approximation of the available memory available on your card through the method JCSystem.getAvailableMemory(...).

Note that it is possible to set a maximum volatile/non-volatile memory size limit during applet installation. So you may be running into a limit that has been set during installation of this specific application. For instance, with gpshell, the parameters of the install command to set memory limits are

  • -nvCodeLimit ... for the maximul non-volatile code memory
  • -nvDataLimit ... for the maximul non-volatile data memory
  • -vDataLimit ... for the maximul volatile data memory

OTHER TIPS

You may have a file cap set. You can check to see how much available memory you have by doing the following:

JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_PERSISTENT);

see this link

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top