0

I am parsing a large xml file using sax parser while displaying to the user by adding to tablelayout with a lot of records. I am getting an out of memory error. In tablerow I am adding textview.

webviewlinear = (TableLayout)findViewById(R.id.webviewlinear);
webviewlinear.addView(tr);
Illidanek
  • 996
  • 1
  • 18
  • 32
mohan
  • 13,035
  • 29
  • 108
  • 178

1 Answers1

0

An out of memory error means that your application has used all the memory that is allotted to it. You should take care to analyze the memory usage of your application and identify the parts that take up the most memory (you mention a lot of records).

In Android applications only have a portion of the device's RAM available to them (to their instance of the Dalvik VM actually). The reason for this is the fact that there is only a small amount of memory on a device and if programmers started to write memory hungry applications, system instability could occur. Therefore you are restricted to only using a small amount of memory in your application and you will have to write efficient code.

I don't know the exact amount of memory and I think it is device specific, but it is somewhere between 16 and 32MB.

You can check out this question for a detailed explanation about how to profile the memory usage of your code.

Community
  • 1
  • 1
Shade
  • 9,936
  • 5
  • 60
  • 85
  • @mohan, I thought I explained in my answer that this is not an error you can "fix". You should inspect your code and minimize the amount of memory it is using. There is no workaround for this error - either you make your code better or it won't run. – Shade Mar 01 '11 at 14:34