Memory management on javacards
843851Feb 11 2005 — edited Feb 24 2005Hi,
I'm working my way through a javacard applet, and now I get 6f00 errors. Of course, only after a couple of commands, so this leads to a memory issue.
Fine, so I try to figure out some stuff, but....
The more and more I work with it, the more I wonder how (IF) it is possible to do dynamic memory allocation.
As I've got a pretty generic class doing something like 'MakeTLVFromThis(bla)' and 'ConstructTLVFromThisData(data)' it's rather impossible to tell how much data it needs to hold. Especially as these can of course be nested TLV's and such. So, ideally I'd use some dynamic memory allocation.
Now, I know that javacards don't necessarily support garbage collection (and the card i'm working with currently probably doesnt - i've been playing around in the JCOP emulator mostly so far). So how do I manage such a thing?
In C, you'd have to free the memory properly (and have some sort of 'destroy()' function to clean up the object. In java, you cannot call for these explicitly (as far as I know), so the objects are stuck in EEPROM forever. Somehow, I can't believe they neutered java and didn't give it anything to play with instead, so, thus leads on to my question:
How do you do dynamic memory allocation/usage on a javacard without garbagecollection?
Regards,
Koos