Search code examples
javaandroidtriesonysony-smartwatch

How to optimize my Trie implementation so that I don't get OutOfMemoryError


I'm implementing text predictions using a very simple Trie implementation, which is a slightly modified version of this code

It performs better than I initially expected, but I'm receiving an OutOfMemoryError frequently. Any ideas how can solve this problem by either:

  • increasing the memory designated to my app
  • optimizing the implementation to use less memory

or any other suggestions?

I've seen recommendations that the memory limitation problems could be avoided by using a native implementation of a part of the code, but I would prefer to stay in Java, if possible.


Solution

  • You could try turning on largeHeap in your manifest to see if it helps:

    http://developer.android.com/guide/topics/manifest/application-element.html#largeHeap