×

Discussion Board

Results 1 to 13 of 13

Thread: Clean cache

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    9

    Question Clean cache

    I use IMB_Range() to clean cache for c++

    Are there any SDK method can clean cache for the java language?

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: Clean cache

    Java memory management is done automatically by a garbage collector thread. Useful post about it:

    http://discussion.forum.nokia.com/fo...ad.php?t=26905

    And from Forum Nokia Wiki:

    This means calls to System.gc()likely add overhead without any benefit (or even cause disruption)
    So, you do not need to call any explicit method to free memory.

    Pit

  3. #3
    Registered User
    Join Date
    Mar 2008
    Posts
    9

    Question Re: Clean cache

    But...

    I wish to clean cache because I attempt to write / read a file.

    I will write data to a file first and read the file.

    I afraid that it will read data from the cache not from the file.

    If I do nothing,does the file read from the file or just from the cache?

  4. #4
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: Clean cache

    You do not need to worry about this, since there's not such a kind of cache File is simply read from real file each time you access it.

    Pit

  5. #5
    Registered User
    Join Date
    Mar 2008
    Posts
    9

    Question Re: Clean cache

    It's bad news...

    I test read /write a file on the SD card by using Outputstream and Inputstream.

    And it read from the cache not from the file.

    How can I solve this problem?

  6. #6
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: Clean cache

    Can you post the code related to file reading?

    Thanks,
    Pit

  7. #7
    Registered User
    Join Date
    Mar 2008
    Posts
    9

    Re: Clean cache

    javax.microedition.io.Connection c = null;

    javax.microedition.io.file.FileConnection fc = null;

    InputStream is = null;

    try {

    fc = (javax.microedition.io.file.FileConnection) fconn;

    is = fc.openInputStream();

    byte byBuff[] = new byte[512];

    int length = is.read(byBuff, 0, 512);


    this.byReadData = byBuff;

    } catch (Exception e) {

  8. #8
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: Clean cache

    Mhm.. some questions

    * Have you tested code on emulator?
    * Does it work there?
    * Have you checked that file is effectively written (on emulator it'll be quite easy to check this)?

    Pit

  9. #9
    Registered User
    Join Date
    Mar 2008
    Posts
    9

    Question Re: Clean cache

    It's the write code.
    It can write and read data when testing on mobile.
    what's the problem?

    try {
    javax.microedition.io.file.FileConnection fc =
    (javax.microedition.io.file.FileConnection) fconn;
    os = fc.openOutputStream();
    os.write(byData, 0, 512);
    for (int dwLoop = 0; dwLoop < dwCacheSize / 512; dwLoop++)
    {
    byData = new byte[512];
    os.write(byData, 0, 512);
    }

    } catch (Exception e)

  10. #10
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: Clean cache

    Do you close your FileConnection, InputStream and OutputStream instances after each read/write operation (from your code I cannot say this)?

    Pit

  11. #11
    Registered User
    Join Date
    Mar 2008
    Posts
    9

    Re: Clean cache

    I have do this... after reading and writing

    os.close(); //io.OutputStream
    c.close(); //io.Connection

  12. #12
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: Clean cache

    What about InputStream instance 'is'? If you do not close it, your second reading operation could cause an IOException (for lack of available InputStreams) and your byReadData variable would not be updated (so you'll still have the data read with the first read operation)

    Pit

  13. #13
    Registered User
    Join Date
    Mar 2008
    Posts
    9

    Re: Clean cache

    When read I also do this...

    is.close(); //InputStream
    fc.close(); //FileConnection

Similar Threads

  1. HTTP Get and cache problem?????
    By berkoron in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2007-04-04, 14:16
  2. How to clear the moile cache ?
    By juankoshy in forum Browsing and Mark-ups
    Replies: 0
    Last Post: 2005-04-06, 07:45
  3. images & cache question
    By larsch in forum Browsing and Mark-ups
    Replies: 1
    Last Post: 2003-07-01, 04:23
  4. Nokia 7650 cache
    By npw in forum Symbian
    Replies: 0
    Last Post: 2002-12-12, 14:06

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •