Android Studio team addresses recent memory leak issues on versions 3.1+
Android Studio’s recent updates have caused some nasty memory leak issues. Users of Android Studio versions 3.1.x and 3.2 Canary versions have reported that the developer tool eats up a ton of RAM. Today, Android Studio Product Manager James Lau posted on Reddit about the issues. He informed users that most of the issues have been addressed.
What memory leak issues?
As James Lau reported, Android Studio 3.1.x included several bugs that messed with garbage collection. Even worse, the newly released Android Studio 3.2 Canary added even more memory leak bugs to the table.
The most serious issue was one where we inadvertently included the sun.misc.Cleaner class in layoutlib.jar, causing serious memory leaks when using the Layout Editor. – James Lau, Android Studio Product Manager
This particular issue only affected the Canary version. There was a misunderstanding on Reddit later that this issue was fixed in Canary 16, but as it turns out, that’s wrong. Mr. Lau verified that the fix is in Canary 17. The table below shows exactly what the issues were, how it affected users, which versions of Android Studio they impacted, and in which version they were fixed.
|Issue||User Impact||Versions Impacted||Versions Fixed In|
|Out of memory / high lag while using layout editor (Issue # 78254948, internal bug)||Android Studio quickly runs out of memory when making use of the Layout Editor or the Preview. Closing the Layout Editor would not fix the problem. Only restarting the IDE would fix the issue.||3.2 Canary||3.2 Canary 17|
|Design Surface is not released as soon as render tasks are done (Issue # 73080536)||Android Studio becomes slower after using the Layout preview or Layout Editor for a prolonged period of time. Android Studio would eventually throw an OutOfMemory exception. Closing the Layout Editor would not fix the problem. Only restarting the IDE would fix the issue.||3.1.x and 3.2 Canary||3.1.3 and 3.2 Canary 16|
|Preview does not release memory from the Layout Editor when closed (Issue # 79535268, internal bug)||Same as above.||3.1.x and 3.2 Canary||3.1.3 and 3.2 Canary 16|
|ScreenViewLayer should release RenderResult after dispose (Issue # 78469702, internal bug||Same as above.||3.1.x and 3.2 Canary||3.1.3 and 3.2 Canary 16|
|Memory leak in DefaultNlToolbarActionGroups (Issue # 73827630)||Same as above.||3.1.x and 3.2 Canary||3.2 Canary 16 and planned for 3.1.4|
|Out of memory when zooming in the Layout Editor. (Issue # 78254948, internal bug)||Android Studio quickly runs out of memory when zooming in and out repeatedly in the Layout Editor.||3.2 Canary||3.2 Canary 14|
As you can see, there’s a lot of bugs that have been addressed. Fortunately, versions 3.1.3 and 3.2 Canary 17 are already available for download and they fix most of these bugs. One of them, issue 73827630, is still unfixed on the 3.1.3 version. Mr. Lau said that the fix hasn’t been backported yet but he promises an Android Studio 3.1.4 update in the coming weeks.
It’s nice to see the team be this transparent about these kinds of issues. Mr. Lau asks developers to report any memory related bug with a heap histogram and apologizes for the program causing memory leaks.
You can see the release notes here. Download links are available below.