This discussion is archived
2 Replies Latest reply: Jul 31, 2012 10:20 AM by safarmer RSS

Applet Memory Allocation

Bluefairy Newbie
Currently Being Moderated
Hi there,
I want to write an applet which stores some data in separated EF and DFs in the file tree. So I created an array with ‘new’ keyword in the constructor of the applet and simulated MF, DF and EF relations in the code. As the user doesn’t know how much space he/she will need in practice I set the size of the array to a big value like 10000 bytes. But the problem is the instance size of the applet which is very big! Because I have created the big array in the constructor of it.
Is there any way to allocate memory after the applet has been installed and when it is really needed? Or each applet needs to specify how much memory it needs before installation?

-Many Thanks
  • 1. Re: Applet Memory Allocation
    816119 Journeyer
    Currently Being Moderated
    you can allocate memory at any time.
    on some cards with carbage collector support you can also free memory.
    but if Shane will answer this question, he will say that allocating at constructor and managing memory by yourself is better, Re: Memory freed
  • 2. Re: Applet Memory Allocation
    safarmer Expert
    Currently Being Moderated
    666 wrote:
    you can allocate memory at any time.
    on some cards with carbage collector support you can also free memory.
    but if Shane will answer this question, he will say that allocating at constructor and managing memory by yourself is better, Re: Memory freed
    Yes I would :) You can use the garbage collector (if it is supported) but I do not like this myself. Is the large applet instance an issue? Do you need more space on the card? Are you an application provider and the instance is created by a third party service provider? There are several things to be aware of in an embedded environment. If you applet size can grow dynamically, it can be difficult to define a profile that specifies how much space your applet uses so others can know how much space to expect to be left on a card with your applet present.

    You could do something like set a hard limit in your code to ensure it does not grow to an arbitrary size. If you know at personalisation time you could also use STORE DATA (with install for personalise) to allocate memory and finalise memory allocation on the final STORE DATA. These are just some thoughts from my caffeine deprived brain :)

    Shane

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points