Alternative to Hashtable? Got lots of data and "OutOfMemoryError"

Hello,
I am working on an application (CLDC1.1 and MIDP2.0, using NetBeans) and have to use a large look-up table with about 50 000 entries. During runtime the application is set to look up entries xxx times from the table, as fast as possible of course. I have used Hashtable for the table data (keys/value) until now, and distributed it all over several files / classes (singleton, static init) with a Hashtable for each class. Have not yet completely inserted the look-up table (about 30% percent left, and .jar size is 300 KB), but now I get the following error: Uncaught exception java/lang/OutOfMemoryError. All hashtables are initialized with a final size.
I should have ca. 2 MB of RAM with the emulator Im using . Printing out freeMemory() from the Runtime I notice that the free mem number decreases fast, towards zero, and then it starts over again - decreasing from somewhere under 2 000 000 bytes down to 0. Not a wiz with debugging, but I guess I have to dive deeper into my garbage collection :)
Is there a better way to store the keys (int) and values (int) of the look-up table? Like an associative array (pseudo): [["key"]=>[value]]
Should I check out RMS (slow?), or some sorts of file handling? Or maybe a combination of Hashtables in memory and also RMS..?
If someone could help with a hint or two, I would be very very thankful!
Tib

50 000 * (4 + 4) B = 400kB of uncompressed data. That's quite a lot for a MIDlet, but it's probably ok if the rest of your application is not so large. Hashtables need more than the size of the data to be effective, so I think an array of key-value pairs (sorted on the keys) would be best here, and of course using binary search when looking up the values.
Or you can look at the range, distribution etc. of the keys, perhaps they will allow some optimization.

Similar Messages

  • Recently lost lots of data and purchases due to Iphone crashing and I had not backed up since Oct. Surely there is a way to recover "lost" PURCHASED music, apps, audiobooks from ITunes, afterall I did pay for these items!  Appreciate any suggestions!

    I've recently lost lots of data and purchases due to Iphone 4 crashing... Surely there is a way to recover "lost" music, apps, and audiobooks which I PURCHASED from ITunes in the last 1.5 months...? Greatly appreciate any suggestions or direction in this matter!

    Note: Previously purchased music is only available through iTunes in the Cloud in Australia, Canada, Cypress, France, Ireland, Luxembourg, Malta, Mexico, New Zealand, Spain, the United Kingdom, and the United States."
    Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • On powering up I got a message date and time were changed to before 2008. Why would this happen?

    I used the computer this morning to check email.  Shut it down and powered back up this afternoon and a box appeared telling me the date and time were set for before 2008 (actually for 12/31/2000) and needed to be reset.  Why would this happen?

    No, it had 3:30 hours left.  I make it a point of not letting it drain.  I haven't had a problem since then, so I'm hoping all is ok.  Thanks

  • ICloud backup storage keeps popping up and I've delete a lot of data and apps for it to have more space, but it keeps popping up and deleting things doesn't work, how do I fix this?

    I've been trying to delete things to make room for more storage but nothing is happening, it keeps saying that iCloud won't backup because there is too much storage. I only have a few apps and I've deleted things I don't use, but nothin is working. How do I fix this?

    http://support.apple.com/kb/ht4847

  • HI, Idid a up grade of my osx mauntain lion and it cancelled all my document, bookmarks and mailboxes it is normal? I have lost a lot of data bacons of it because i did not do the back up of all my files just the back up of my photos. . .what can i do

    HI,
    Since a while I have received from apple the warning for an up grade for my Os x Mountain Lion and finally I decider to do it. . . . and since it was just an up grade I DIDN'T DO A BACK UP of all the content of my book pro because I thought it wasn't necessary . . . .but when I did it . . . . .it cancelled me all my files in documents, most of all my mail boxes in mail and most of my bookmarks in safari.
    I do not understand why; since i did not change my os but just did an up grade of my existing one. . . . . .result I lost a lot of data and I do not know what to do.
    Is this normal that it cancelled data in my documents folders and in others parts of my mac pro ?? ? ? . . . .ad if it is so why don't you write a warning saying that before going through  with a simple up grade  of your OS of your computer everybody should do a back up of everything it has in it ?!?!?!
    Buongiorno,
    Da qualche tempo mi era avvivato l'annuncio da vii di apple che c'era un ap grade per il mil system operative per il mio Os x mountain lion e alls fine ho deciso di faro . . . . .siccome era solo un au grade del systema operativo e non un cambiamento per un Os più recente non ho fat to un back up di tutti il contenuto del mio mac pro . . . .ma dope averlo fat to l'up grade ho realizzato che il procedimento mi aveva cancellato tutti i file contenuti nei midi document, le mailbox che avevo create in mail e i bookmarks che avevo create in safari . . . . . .e forse anche altre cose che non ho ancora visto.
    Ma è normale che questo succeda e se si perchè insiemme all'annuncio di dover fare un'up grade non mettete anche una segnalazione sul fatto che prima di procedere è consigliato  fare un back up di tutti i datti che si ha nel computer ?
    Io adesso mi trovo nella scomoda posizione di aver perso dei dati importanti con perdita di tempo e lavoro.

    What happened isn't normal, but does demonstrate why you need a backup, preferably two.
    Data Recovery – Best
    Data Recovery – Disk Drill
    Data Recovery – Data Rescue
    Data Recovery – File Salvage
    Data Recovery – Stellar Phoenix
    Data Recovery - uFlysoft
    Data Recovery - Recovering Deleted Files
    Data Recovery - Recovering Deleted Files (2)

  • I use a SpeedPort W700V as WiFi Router. SpeedPort encrypt the WiFi data and iPAD doesn't deencrypt the WiFi data. How to initialize the Encrypt / Deencrypt function of iPAD ? (including shared keys)

    I use SpeedPort W700V from German Telekom as router for my WiFi and DSL access. DSL connection to Internet is proper running, WiFi with iPAS does only work if I switch of the Encryption mode of SpeedPort (Standard parameter in SpeedPort is WPA2 with shared key PSK).  Who can give a hint how to switch on the encryption / deencryption mode of iPAD 2. 3G Sim Card is currently not installed.

    Thanks for the quick response. No, I did not get any error messages or any terms-of-usage screen. The employee I told my problem to was not computer savvy either. She just suggested I move to different spots w/in the library to see if that would make a difference. It didn't. When I connected to the library WiFi it did change the Verizon 3G that is usually in the upper left corner to iPad with two to three emanating arcs. I may have to go to the library in the next town. I was able to connect to theirs in the past when I had to download something greater than 20 MB. Unless I really want it, I will probably not even try to download something more than 20 MB due to the hassle. Yeah, I may have been better off getting a normal desktop or laptop and getting WiFi at home. To do that now would mean having my iPad 2 and a desktop computer, which I feel is extravagant. (I know there are a lot of big spenders out there who got the iPad as additional gadget for fun. This is a rich country.) A Verizon rep told me I couldn't set up a WiFi router at home just using an iPad. So it seems like a person who just uses 3G is limited to surfing the net (not even much YouTube because it eats a lot of data) and using email. I read about an app that helps print wirelessly using 3G, but a reviewer said you had to be an engineer to get it done right. BTW, I like the Steelers. I'm old enough to remember Franco Harris and that blond guy whose name escapes me back in the '70s. Since I live in North Jersey I feel I have to support the Giants. But I know football about as well as computers.

  • How to get fiscal period based on date and Fiscal year?

    Hi Guys,
               Can anybody tell me how to get Fiscal period based on date and Fiscal Year or fiscal year variant?
    Thanks,
    Gopi.

    Hi,
    Please refer the code below:
    *: Report:  ZFISCALYR                                                  :
    *: Date  :  2004                                                       :
    *: Description: Demonstrates how to return the corresponding fiscal    :
    *:              year and posting period for a company code and posting :
    *:              date or posting date and fiscal year variant.          :
    REPORT  zfiscalyr NO STANDARD PAGE HEADING.
    TABLES: ekko.
    PARAMETERS:     p_bukrs TYPE ekko-bukrs,
                    p_bedat TYPE ekko-bedat.
    DATA: gd_fiscalyr  TYPE bapi0002_4-fiscal_year,
          gd_fiscalp   TYPE bapi0002_4-fiscal_period.
    DATA: gd_fiscalyr2 TYPE T009B-BDATJ,
          gd_fiscalp2  TYPE bapi0002_4-fiscal_period.
    DATA: gd_periv     TYPE t009-periv.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    * get fiscal year and period - (requires date and company code)
      CALL FUNCTION 'BAPI_COMPANYCODE_GET_PERIOD'
        EXPORTING
          companycodeid = p_bukrs
          posting_date  = p_bedat
        IMPORTING
          fiscal_year   = gd_fiscalyr
          fiscal_period = gd_fiscalp.
    * Alternative fiscal year function module
    * - (requires date and fiscal year variant code from T009 table)
    * gets first entry in fiscal year variant table (will need to choose
    * correct one from table rather than just using first entry)
      SELECT SINGLE periv
        FROM t009
        INTO gd_periv.
    * get fiscal year and period
      CALL FUNCTION 'DETERMINE_PERIOD'
        EXPORTING
          date                      = p_bedat
    *    PERIOD_IN                 = '000'
          version                   = gd_periv
       IMPORTING
          period                    = gd_fiscalp2
          year                      = gd_fiscalyr2
       EXCEPTIONS
          period_in_not_valid       = 1
          period_not_assigned       = 2
          version_undefined         = 3
          OTHERS                    = 4.
    *END-OF-SELECTION.
    END-OF-SELECTION.
      WRITE:/ 'From function module: BAPI_COMPANYCODE_GET_PERIOD',
            / 'Fiscal year is:', gd_fiscalyr,
            / 'Fiscal period is:', gd_fiscalp.
      SKIP.
      WRITE:/ 'From function module: DETERMINE_PERIOD',
            / 'Fiscal year is:', gd_fiscalyr2,
            / 'Fiscal period is:', gd_fiscalp2.
    Thanks,
    Sriram Ponna.
    Edited by: Sriram Ponna on Apr 17, 2008 8:59 PM

  • I recently got the iPhone 4s, but my iPod has a lot of apps with a lot of data on them and don't want to start over. I already synced my iPhone from the computer that had all my apps from my iPod, how do i transfer the data over, the other apps did.

    I recently got the iPhone 4s, but my iPod has a lot of apps with a lot of data on them and don't want to start over. I already synced my iPhone from the computer that had all my apps from my iPod, how do i transfer the data over, the other apps did. But some reason the app Clash Of Clans did not. Thank you.

    If I wiped my phone I wouldn't have the contacts on my phone to send to my self.    I would need to take just the contacts from my back up. I would have to do this through iTunes and I don't see how I can just extract the contacts only from my back up. From what I can figure out it is all or nothing

  • REPORT TO CHECK DIFFERENCE G.R DATE AND U.D DATE FOR A INSP LOT

    Hi
    I want to track how many dates it has been taken to clear a insp lot for a G.R. So I am looking for a report which shows these days or a report which have G.R date and U.D for inspection lot.
    Please guide if there are any reports for this.
    Thanks
    Dhananjay

    Dear Dhananjay
    This is available in MCXA, MCXC report as lead time. Lead time is nothing but time taken for clearing the lot after GR
    Regards
    Gajesh

  • I just got iphone 5c and i am not happy with it. It uses to much data and i don't even know how. I can't get the ringtones i want for my contacts.I got it on my free upgrade but i want to take it back and get something else but where i got it they say i c

    I just got iphone 5c and i am not happy with it. It uses to much data and i don't even know how. I can't get the ringtones i want for my contacts.I got it on my free upgrade but i want to take it back and get something else but where i got it they say i can't because i don't have the earbuds and i have serches or them. now i am suck with a phone i don't like at all until my next upgrade. this is very dishearten

    1. If you are this unhappy with that phone, and the lost earbuds is the only thing stopping you from taking it back, why do not just buy some earbuds. That way you can get rid of that phone. It all depend upon how much you want to get rid of that phone.
    2. Yet if you are stuck with that iPhone, here is something might help you to control the data usage. By design, iPhones do turn off WiFi when they go dormant. So if a download is in progress and so forth when the phone goes dormant, it will switch to use cellular data, if this setting is left on. Therefore, from multi-sources I have learned that if you keep your iPhone connected to a power source, then it will stay connected to the available WiFi.

  • ICal reports that it can't find server, and lots of data from several years ago is trying to get attention.  Cannot bring up calendar in any view to use. also keeps loading unused calendar websites from long ago.  I can' remove them. what to do?

    iCal reports that it can't find server, and lots of data from several years ago is trying to get attention.  Cannot bring up calendar in any view to use. also keeps loading unused calendar websites from long ago.  I can' remove them. what to do?

    UPDATE: I had 36 Safari windows open and minimized on the dock from my last session; 20 of those windows failed to open b/c Safari "couldn't find the server"; I just went to the URL bar of all 20 pages and clicked return, and all 20 pages loaded perfectly, without dropping any images or losing formatting. This is a puzzle!!!

  • ICloud password works on everything but erasing all data. I got a new iPhone and need to wipe this one but am not sure how else to do this since the password is not working. Any suggestions?

    iCloud password works on everything but erasing all data. I got a new iPhone and need to wipe this one but am not sure how else to do this since the password is not working. Any suggestions?

    Firefox also makes regular backups of your bookmarks in a folder named bookmarkbackups in your personal settings folder. You can restore the backup to your new Firefox, but unlike importing the HTML-format file, it is a complete drop-in replacement, so if you have saved new bookmarks you do not want to lose, the export/import method may work better for you.
    By default, Windows hides your personal settings folder so the easiest way to access it is from inside Firefox. You can use either:
    * "3-bar" menu button > "?" button > Troubleshooting Information
    * (menu bar) Help > Troubleshooting Information
    * type or paste about:support in the address bar and press Enter
    In the first table on the page, click the "Show Folder" button. This will launch a window showing your Firefox settings files.
    You might want to back up this whole folder if you have other data you want to preserve from your XP computer.
    Either way, you should find the bookmarkbackups folder here and when you click into it, find maybe 10 files with dates in their names.
    The procedure to restore the file once you have it on removable media or some other convenient place is described in this article: [[Restore bookmarks from backup or move them to another computer]].
    Regarding the other files and what you might find of use: [[Recovering important data from an old profile]].

  • I just got a new iPhone and i set up iCloud on my girlfriend's account. To change it on settings it says delete account. Will this delete her all her data and back up data for iCloud on her iPhone and iPad?

    I just got a new iPhone and i set up iCloud on my girlfriend's account. To change it on settings it says delete account. Will this delete her all her data and back up data for iCloud on her iPhone and iPad? Can i change it without deleting it? Please help.

    Delete the account on your phone. This will not delete any data on her phone or iPad, or data stored in iCloud.

  • My iPhone was stolen. I just got a new one and am trying to backup my contacts and data from iCloud. How do you do that?

    my iPhone was stolen. I just got a new one and am trying to backup my contacts and data from iCloud. How do you do that?

    If your backup is in iCloud, and your new iPhone is already set up, go to Settings>General>Reset, tap Erase All Content and Settings, then go throught the setup screens on the iPhone and when given the option, choose Restore from iCloud Backup and follow the prompts.  (If it isn't set up yet, just choose this option when setting it up.)
    Be sure your iPhone it connected to wifi and your charger while it is restoring the backup.

  • I got a new computer and need to sync my iPhone and iPad on it, how do i do that without losing all data.

    I got a new computer and need to sync my iPhone and ipad on it, how do i do that without losing all data. I need help ASAP!

    If you still have the old computer see: http://support.apple.com/kb/HT4527
    If you don't have your old computer, but you made regular backups of it, restore the most recent backup using the backup software that you used to make the backup. You will have to read the instructions for it.
    If you don't have your old computer and you did not back it up regularly see: Syncing to a "New" Computer or replacing a "crashed" Hard Drive

Maybe you are looking for

  • -36 I/O Error copying from one external drive to another? Ugh...help?!?

    Hardware: Apple Powermac Dual 2.5 GHz G5 512 MB RAM External Drive 1: LaCie 250 GB (Firewire 800) (contains 150 GB data) (formatted MacOS Extended) External Drive 2: LaCie 400 GB (Firewire 800) (contains NO DATA) (formatted MacOS Extended Journaled)

  • Problem with Using JDBC in Applet

    Hi, i have written an applet to log in (it checks the database, if the username and pasword exists it shows corresponding message). i use access or sql server and applet is started but no message is shown(i think it does not connect to database). her

  • REcreate physical standby from New Primary

    Dear Experts; My Production db 11G R1 os was crashed so I had to trigger failover at my physical standby (New Primary). I recreated Crashed Primary as Standby from New Primary mentioned above with Hot backup Now question is that I have successfully S

  • Possible to Set iCal Calendar as Desktop Background?

    Can it be done? Is there some clever plug-in somewhere that makes it possible? Thanks for your help. Dan

  • Zsh: "set | grep foo" show my not the result...

    hello! i have "successfully" switched to zsh! i must say: its amazing!!! but i have one problem: i often use commands like this: $ set | grep foo but i get this: hit: $ set | grep foo Binary file (standard input) matches no hit: $ set | grep foo what