简体   繁体   中英

LazyList memory leak in Jetpack Compose

I found out that LazyList generates memory leaks. When I scroll down to the bottom of the list memory usage by my app increases by ~3MB. After I scroll up and usage also increases by ~3MB. Memory usage increases all the time is scroll list. How to fix it? Issue on Google IssueTracker

PS Sometimes memory usage drops down by 50-100mb. In my test project(code below) usage grows up to 150mb. In my other, more complex projects it grows up to 200-250mb. In a theory it can cause OutOfMemoryException.

Example:

 LazyVerticalGrid(columns = GridCells.Fixed(2)) { item(span = { GridItemSpan(2) }) { LargeTopAppBar(title = { Text(text = "Explore new") }) } items(50) { Box(modifier = Modifier.fillMaxWidth().height(250.dp)) } }

This issue is already reported and as of now still not resolved.

In a theory it can cause OutOfMemoryException.

Not only in theory as we recently had to downgrade a production version of an app back to Compose 1.1.1 due to this exact issue. As far as I know this is the only possible solution for now.

I guess we should stick to stable versions of Compose from now on.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM