×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    58

    HashTable is causing out of memory error

    Dear all,

    I am creating a list in which i display 7-8 fields. So am retrieving all the data from RMS in a hashtable:

    HashTable ht = new HashTable();
    ht.put("id", "first name#last name#age#gender#address#phone number#bank name");

    After this method free memory is: 142756 kb

    On other side if i create 2 dimensional string array or vector to store this information, 652588 kb free memory remains. So, Hashtable is more efficient but causing me out of memory exception when list size increases. Can you suggest me which one i should use, which is more efficient for huge list because heap size is very limited (2MB approx)

    Testing mobile handset : nokia C101
    Free Memory Method : Runtime.getRuntime().freeMemory()

    Thanks

  2. #2
    Regular Contributor
    Join Date
    Dec 2012
    Location
    India
    Posts
    265

    Re: HashTable is causing out of memory error

    If you run out of memory, try lazy loading.Retrieve the contents part by part,instead of the entire list at a time.As the list is scrolled, get more data from the RecordStore and continue populating the list.

  3. #3
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,073

    Re: HashTable is causing out of memory error

    Quote Originally Posted by jayantb View Post
    Dear all,

    I am creating a list in which i display 7-8 fields. So am retrieving all the data from RMS in a hashtable:

    HashTable ht = new HashTable();
    ht.put("id", "first name#last name#age#gender#address#phone number#bank name");

    After this method free memory is: 142756 kb

    On other side if i create 2 dimensional string array or vector to store this information, 652588 kb free memory remains. So, Hashtable is more efficient but causing me out of memory exception when list size increases. Can you suggest me which one i should use, which is more efficient for huge list because heap size is very limited (2MB approx)

    Testing mobile handset : nokia C101
    Free Memory Method : Runtime.getRuntime().freeMemory()

    Thanks
    Define - what is required to done on the list - search / sort / scroll etc... based on the requirement you need to fetch or create data-map for needs. Lazy loading is the way going forward when playing large data set on small memory device - we can try some type of map-reduce thing -- in the hashtable - just store id and key field (instead of full data row) - then you can search on the key field in the hashtable - get its id and fetch the data row from RMS when needed to display.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  4. #4
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    608

    Re: HashTable is causing out of memory error

    How big is your data? how many records do you have?
    Why are you trying to load them all to the heap at the same time? can you do as arunkam suggested lazy loading?
    In general HashTable does take more space thatn simple array of course.
    If your dealing with Strings only and MUST have all the data in heap memory and need speed of HashTable to retrieve them by ID and your limited by memory.
    then i would suggest you try doing text compression of your strings with known algorithms such as Huffman coding (this will mean that anytime you want to write/read a string it will take a bit longer since it needs to be coded/decoded but it will reduce your heap size by a lot if you use it properly.

Similar Threads

  1. HashTable - Out of Memory
    By Mr.Bond007 in forum Mobile Java General
    Replies: 2
    Last Post: 2010-01-07, 11:13
  2. fopen,fclose causing memory leak
    By lakshmi.prasanna in forum Symbian
    Replies: 6
    Last Post: 2009-07-17, 14:58
  3. Replies: 2
    Last Post: 2005-07-25, 06:07
  4. Replies: 0
    Last Post: 2005-04-19, 09:03
  5. Hashtable memory performance
    By yonan32 in forum Mobile Java General
    Replies: 0
    Last Post: 2004-02-18, 06:30

Posting Permissions

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