java - Is there an optimum point between saving data in memory and writing it to drive? -
i'm developing j2me application (with sdk 3.4) unused j2me se hazel j20i record gps data via location api.
neither cldc 1.1, midp 2.1, nor jsr-75 provide java.io.bufferedwriter. manually.
how have store gps readings (gps logging run indefinitely until stopped) in memory (variables) until have write on disk?
what best performance?
knowing write/read hard drive (sd card, etc.) cost more write/read memory (ram) suggest keep track off memory available while collecting gps data , define threshold write data hard drive. cannot tell optimum threshold. can keep track of memory that:
long totalmemory = runtime.getruntime().totalmemory(); long freememory = runtime.getruntime().freememory(); if(threshold > freememory) //1-write hard drive //2-make sure use proper mechanism //garbage collector (gc) job. ex: reinitialize data structures, set them null ...
note gc might take time before clearing memory, need handle because after clear data structures free memory wont become bigger right away 0 before gc job , won't go out of memory. don't need remind you have handle out of memory scenario! have nice day.
Comments
Post a Comment