Thread objects not garbage collected after being finished

后端 未结 4 1819
遥遥无期
遥遥无期 2021-02-08 13:28

I noticed that my application is leaking memory. This can be seen in DDMS, and I managed to get a OutOfMemoryError.

I found the source of the leak. One of the activitie

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-08 14:16

    I have just figured out this same problem.

    Tomasz, you are on the right track. There is NO bug in DDMS and there is NO memory leak in your program.

    The really problem is you are running your program in DEBUG mode (under Eclipse). Somehow when Android is running in DEBUG mode, Threads are not garbage collected even after the run() method has been exited. I guess it is probably Android needs to hold on to the Thread for some debugging features to work.

    But if you run you application in RUN mode (still under Eclipse), Thread garbage collection takes place. The Thread will be freed completely and your Activity will be freed completely.

提交回复
热议问题