getting out of memory error
<p>I am trying to load a 12mb txt file into memory as a HashMap to make it available for the application to use it but I am getting an OutOfMemoryError</p>

<pre><code>09-27 15:42:17.560: ERROR/AndroidRuntime(19030):     ... 11 more
09-27 15:42:17.560: ERROR/AndroidRuntime(19030): Caused by: java.lang.OutOfMemoryError
09-27 15:42:17.560: ERROR/AndroidRuntime(19030):     at java.util.HashMap.makeTable(HashMap.java:559)
09-27 15:42:17.560: ERROR/AndroidRuntime(19030):     at java.util.HashMap.doubleCapacity(HashMap.java:579)
09-27 15:42:17.560: ERROR/AndroidRuntime(19030):     at java.util.HashMap.put(HashMap.java:409)
09-27 15:42:17.560: ERROR/AndroidRuntime(19030):     at org.com.SentencesActivity.loadBigramFrequencies(SentencesActivity.java:151)
09-27 15:42:17.560: ERROR/AndroidRuntime(19030):     at org.com.SentencesActivity.onClick(SentencesActivity.java:56)
</code></pre>

<p>Is there any way to solve it or it is a limitation of dalvik vm?</p>

<p>Code for loading the file into memory:</p>

<pre><code>public HashMap&lt;String, Double&gt; loadBigramFrequencies() throws IOException {
        AssetManager assetManager = getAssets();

        HashMap&lt;String, Double&gt; bigramFrequencies = new HashMap&lt;String, Double&gt;();
        String[] splittedLine;
        try {
            // open the file for reading
            InputStream instream = assetManager.open("bigramFrequencies.txt");

            // if file the available for reading
            if (instream != null) {
                // prepare the file for reading
                InputStreamReader inputreader = new InputStreamReader(instream);
                BufferedReader buffreader = new BufferedReader(inputreader);

                String line;

                // read every line of the file into the line-variable, on line
                // at the time
                while ((line = buffreader.readLine()) != null) {
                    // do something with the settings from the file
                    splittedLine = line.split("\\#");
                    bigramFrequencies.put(splittedLine[0].trim(),
                            Double.parseDouble(splittedLine[1].trim()));
                }
                Log.v(LOG_TAG, "bigram frequencies loaded");

            }

            // close the file again
            instream.close();

        } catch (java.io.FileNotFoundException e) {
            // do something if the myfilename.txt does not exits
        }

        return bigramFrequencies;
    }
</code></pre>
