2

I have created a client/server pair with two threads to send and receive objects, While it runs fine at the beginning I'm experiencing an OutofMemory error when it runs for a while, I was looking out how te garbage collector works in Android 2.3.4 and it seems that some objects are kept by the ObjectInputStream and ObjectOutputStream from being collected by the GC. I used the Memory Analysis Tool in Eclipse to find out where the memory leak is located and found that there is a IdentityHashMap object that keeps the reference to te data being sent and received. I will like to find out a way around this issue on how to release this data or how to remove the reference this object keeps on my data preventing it from being collected. The memory heap I'm working with is pretty big for a cell phone 64M, and if I try the same with big chunks of data it works fine, as long as I don't run it for very long.

4

1 回答 1

0

问:你在任何时候都在做“reset()”吗?

对象流会记住写入它们的每个对象,除非您重置它们。

于 2013-03-06T22:32:00.967 回答