Skip to Main Content

Java Card

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Java Card 3.0.2 - Garbage Collection

user11216344Feb 3 2018 — edited Apr 10 2018

I am using a NXP J3D081 80K I am compiling against 3.0.2. I am trying to simulate a simple file system. The Write routine is simply:

public class File {

   public File Next;

   public byte[] Name;

   public byte Attributes;

   public short Length;

   public short Ptr;

   public byte[] Data;

  

   public byte Write(byte[] InData,short Offset, short InLength) {

       if (Length == 0) {

            Data = new byte[InLength];

       }

       else {

           byte[] tmp;

           tmp = new byte[(short)(Length+InLength)];

           Util.arrayCopyNonAtomic(Data,(short)0, tmp, (short) 0, Length);

           Data=null;

           Data=tmp;

           tmp=null;

       }

       Util.arrayCopyNonAtomic(InData,Offset,Data,Length,InLength);

       Length += InLength;

       return(1);

   }

....

}

I am trying to append data, so I allocate a new buffer the full size of the file, copy the old data in and then copy in the new data. It was my understanding that this card has garbage collection so the old byte array should be collected at some point, but I am returning JCSystem.getAvailableMemory(JCSystem.MEMORY_TYPE_PERSISTENT); and it shows that the memory available goes down by the size of the existing data array, so it is not garbage collected. Even after a power down/up of the card, the memory is not reclaimed.

What am I missing?????

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on May 8 2018
Added on Feb 3 2018
2 comments
1,969 views