How to get a java card memory size info ?

Hi everyone ,
I want to get my card's memory size and free memory size .I appreciate it if anyone could help me with these questions :
1 . Is there any way to find out card's defferrent memories size (EEPROM , ROM , RAM , FLASH) from Get Data command or any other apdu commands ?
2 . is there any function in the API which we could use to reach memory size within an applet ? I found a function named GetMemorryAccessInstance in JCRE 2.2.2 API but I need something more global for all API versions .
3 . Which Memories size information do we have access to ?
Best Regards,
Shemeine

Hi Shemeine,
Some cards have proprietary APDU's to find the free memory on a card. Even on cards that have such an APDU, you may have to have it enabled when the card is produced.
As for a way to find it programatically, you can use:
JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_PERSISTENT);
JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_TRANSIENT_DESELECT);
JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_TRANSIENT_RESET);The problem with these is they return a signed short. This will only show up to 32KB of free memory. If you have more than this, you will have to allocate some memory using new byte[32*1024] until you start seeing results less than 32KB. You then work out how many blocks of 32KB you had to allocate to reach this state. The types of memory you can find are self explanatory.
Cheers,
Shane

Similar Messages

  • Java Card Memory Managament: How do you free-up allocated memory?

    I have a problem with java card memory management, that causes the applet to hang. I think the java card runs out of RAM when my applet runs for several iterations or process() calls. My program requires significant size of bytes for each APDU command to be sent. (around 100-250 bytes, for each apdu.sendBytes() call).
    I use a temporary byte array buffer that will contain the APDU command to be sent, declared as:
    private byte [] tmpBuff;Before each process() call, the tmBuff is initialized and contains a new byte array containing the APDU command to be sent. (array size around 100-250 bytes).
    tmpBuff = new byte[] {0x00, ... } On the process() call, the tmpBuff is copied to APDU and sendBytes() function is called. The tmpBuff byte array is reinitialized after every process() call to contain the next command. After about 20 successful commands by the process() call, the applet seems to ran out of RAM and hangs.
    I suspect, that when tmpBuff is reinitialized before each process() call, the Java Card garbage collector does now free-up the memory that was used for the previous tmpBuff byte array initialization.
    Is there a way to reclaim the memory allocated for tmpBuff after it has been initialized?
    Or maybe call the Java card garbage collector?

    Cenon,
    Generally speaking, the new keywork is a bad idea outside the install method or constructors as the JCRE is not guarenteed to have a garbage collector (and if it does, has to be called explicitly by JCSystem.requestObjectDeletion(); This however is slow.
    A better option may be to use memory more efficiently than to rely on garbage collection. A way of doing this would be to have an instance variable that is initialised once and reused. This allows you to use either a transient or persistent array.
    public class TestApplet extends Applet {
        private final static short BUFFER_SIZE = (short) 300;
        private final byte[] buffer;
        private TestApplet() {
            // only have one of the following not commented out
            /* persistent buffer */
            // buffer = new byte[BUFFER_SIZE];
            /* transient buffer (much faster) */
            buffer = JCSystem.makeTransientByteArray(BUFFER_SIZE, JCSystem.CLEAR_ON_DESELECT);
        public static void install(byte[] bArray, short bOffset, byte bLength) {
            // GP-compliant JavaCard applet registration
            new TestApplet().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
        public void process(APDU apdu) {
            // Good practice: Return 9000 on SELECT
            if (selectingApplet()) {
                return;
            // do some work here with buffer
    }In the above code you would be able to use the buffer to build the command and you will not have a memory leak.
    Cheers,
    Shane
    Edited by: safarmer on Jul 8, 2008 12:25 PM

  • How to get  Network Interface Cards information ?

    hi all,
    how to get Network Interface Cards information and tcp window size by java ?

    807262 wrote:
    how to get Network Interface Cards information Have a look at [url http://download.oracle.com/javase/6/docs/api/java/net/NetworkInterface.html#getNetworkInterfaces%28%29]NetworkInterface.getNetworkInterfaces()
    tcp window sizeWhich one?
    SO_RCVBUF ^[url http://download.oracle.com/javase/6/docs/api/java/net/Socket.html#getReceiveBufferSize%28%29]Socket.getReceiveBufferSize()^
    SO_SNDBUF ^[url http://download.oracle.com/javase/6/docs/api/java/net/Socket.html#getSendBufferSize%28%29]Socket.getSendBufferSize()^

  • How to load a java card applet into a java card

    Dear All,
    I am a novice to java card technology..
    I have done some search on how to load a java card applet into a smart card but haven't found a satisfactory answer. I have read about installer.jar and scriptgen tool but I want to load the applet from a java program and not from command line. It would be of great help if somebody can help me out.
    If somebody can share a sample program which load a javacard applet(.CAP file) into a smart card, I will be very thankful.
    I am able to find some client applications which help us send APDU commands and recieve response APDU's to interact with an applet loaded on to the smart card but not application which actually load the applet.
    I have heard of OCF and GP.. some say that OCF technology is outdated and no longer in use.. can somebosy throw some light on this too..
    cheers,
    ganesh

    hi siavash,
    thanks for the quick response.. i checked out GPShell as suggested, it looked like a tool by which one can load an applet on to card and send some sample apdu commands... but I want to load the applet from the code.
    My application should look something like this.. it will be a swing applicaton where I have a drop down with a list of readers, I select the one desired and then click on "LOAD" after inserting a blank java card, at this point my applet which is stored in my DB should get loaded on to the java card. The next step should be to personalize it where I enter the values for the static variables of my applet and click "PERSONALIZE", at this point all these values should be embedded into APDU commands and sent to the java card for processing.
    For achieving this I am yet to find a comprehensive sample or documentation on the net.
    Please help...
    regards,
    ganesh

  • How to get the java code of the message mapping

    how to get the java code of the message mapping,
    I mean to ask how to get the background java code of the message mapping(graphical mapping).
    And where to view it?

    Hi Satya,
    The JAVA code for graphical msg mapping is in below folder:
    \usr\sap\<SID>\<DVEBMGS10>\j2ee\cluster\server0\temp\classpath_resolver
    Here all the mapping jars are there in this folder.
    Just decompile these jars and you can see the code.
    Thanks,
    Rajeev Gupta
    Message was edited by:
            RAJEEV GUPTA

  • I modified the first business card in a template. Does anyone know how to get the other cards on the template to look like the first one without doing each individually? please and thanks!

    I modified the first business card in a template. Does anyone know how to get the other cards on the template to look like the first one without doing each individually? please and thanks!

    http://www.freeforum101.com/iworktipsntrick/viewtopic.php?t=182&mforum=iworktips ntrick
    Peter

  • How  to get the java code of the standard functions

    How  to get the java code of the standard functions in xi
    Example , hoh get the java code for a node function - removeContext.

    hi
    Click on the Standard Function.
    Hold Ctrl+Shift
    right click on the standard function to view the context menu. You will see options to view the source code by exporting
    regards
    krishna

  • How to get micro sd card to work

    how to get micro sd card to work.. my phone says total space 7.40GB for sSD card and that's whats available. I put a micro SD card in but no change?

    You put the card in and go to settings and go to storage and scroll down to sd card and click mount ad card

  • HT1459 how to get lost warrenty card for IPOD touch 5

    how to get lost warrenty card for IPOD touch 5

    Just go to the App Store and download them all again.
    Basic troubleshooting steps  
    17" 2.2GHz i7 Quad-Core MacBook Pro  8G RAM  750G HD + OCZ Vertex 3 SSD Boot HD 
    Got problems with your Apple iDevice-like iPhone, iPad or iPod touch? Try Troubleshooting 101

  • HT201209 how to get itunes gift cards and itunes gifts

    i have purched iphone 4s 8gb, but not able to register without itunes gift cards and itunes gifts
    Can you help me how to get itunes gift cards and itunes gifts

    iTunes Gift Options  >  http://support.apple.com/kb/HT2736
    Note:  iTunes Gift Cards are only Valid in Country of Issue

  • How to get the Pdf's page size?

    Hi,
    Anyone can tell me how to get the pdf's page size with js in acrobat?
    Regards
    Goldbridge

    The page size will not always necessarily conform to a standard size such as A4 - PDFs can be defined at any abstract size a user wants. Having a function that only output standard sizes would greatly limit its ability, so it was left up to the user to calculate whether or not the returned rectangle is a standard size as that satisfies many more workflows than the opposite method.

  • How do get rid of the Pop Up Info Tags?

    This might sound Stupid, but how do get rid of the Pop Up Info Tags? that keep coming up on the Mac when in an Application that says what this item is for. This drives me crazy, and at times gets in the way of what I'm looking at. There must be some Pref to turn this off and on, I Hope.
    Anyone?
    ScottG
    G5 Dual 2.3   Mac OS X (10.4.3)  

    ScottG wrote: "I guess Safari doesn't have this option?"No, it does not. If an app offers the option, it will be in its preferences. It's rare nowadays for an application to offer a preference for disabling tool tips, especially after the developer went to all the trouble to provide them.
    Simply move your cursor off the control displaying the tool tip: the tip will vanish.
    Good luck!
    Dr. Smoke
    Author: Troubleshooting Mac® OS X

  • How can I choose java card?

    I'm new for smart card.
    I want to do project about security (It use authentication by MAC.) How can I choose the card and reader/writer? Have vender in thailand?
    If I bought normal smart card and reader/writer, can I write java on it? If it's possible , how can I do?
    Note that: I want only basic java card.
    Thanks

    I go to Schlumberger website. I found e-gate SDK kit ID. 401140.
    I want to know that it have more basic can I get to do my project?
    About gemplus? I go to gemplus website too, but I don't found more enough information to decided.
    Cloude you advise version of card and reader that can I get to do my project? (I have budget about $250)
    Can it work with Java Card 2.2 Development Kit by sun, if I buy only card and card reader?
    Thanks,

  • Where to get Hardware (Java Card & Readers)

    Hello
    I am new to Java Card Technology. well i have Downloaded the Java Card 2.1.2 Devlp Kit. Thats fine , But from where should i get Hardware like Java Cards & Readers. I am working in Research Institute.
    & wat are the steps to start with it.
    Please guide me soon.

    Sun doesn't provide cards or readers. Their kit is serves two purposes. One is for the integrators that are shipping cards and readers. The other purpose is for developers to learn how to develop applet without a card. For example, no one is shipping 2.1.2 cards yet,( I don't think) but you can still develop a 2.1.2 applet with Sun's kit. You just won't have a card to deploy you applet to.
    If you develop a 2.1.1 applet you can use Gemplus cards and deploy your applet there.
    If you want to start developing go to www.javasoft.com/products/javacard. Download a sdk, and read tutorials.

  • How to start with java card

    hello,
    i'm new to java card n know a bit of core java.. my superior of company asked me to get complete knowledge on java card.. iworked for 1 month on native cards..n know a bit of gsm 11.14. I want a favour.
    my queries:-
    a) how and from where should i start
    b) wat all basics i need to know &
    c)how to work on this card.
    ANY REPLY WILL BE APPRECIATED..
    Thanks

    a)
    - Look at Sun's tutorials on Java Card.
    - Z. Chen's book from Sun about smart cards gives you deeper knowledge about the Java Card technology.
    - Furthermore there is a great reference book about smart cards in general from W. Rankl.
    b)
    - Java: You should have basic understanding and knowledge about Java.
    - Java Card: is a subset of Java, but you need to be much more aware of the Java Card VM and RE.
    - You need to have some specifications at hand
    - Java Card API, VM and RE
    - GlobalPlatform
    - ISO 7816 and ISO 14443 for CL
    c)
    - There is a number of smart card operating systems.
    - I recommend the Java Card Open Platform (JCOP) from IBM/NXP. There is a good developer environment (JCOP Tools plugin for Eclipse) where you can start developing against a smart card SW simulator.

Maybe you are looking for