-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OutOfMemoryError
comes back when targeting android 31
#6872
Comments
If I make the following change the workaround, I still have // https://github.com/robolectric/robolectric/issues/2584
val windowData = Reflection.staticField("WINDOW_DATA").ofType(Any::class.java)
- .`in`(ShadowCursorWindow::class.java).get()
+ .`in`(ShadowLegacyCursorWindow::class.java).get()
val dataMap =
Reflection.field("dataMap").ofType(MutableMap::class.java).`in`(windowData).get()
dataMap.clear() |
Can you add Also what's the max heap size that is being used? I typically recommend |
I'll check those jvm flags in a moment. I just wanted to also note here that I tried setting the following, and it didn't solve the problem: testOptions {
unitTests {
all {
...
systemProperty 'robolectric.sqliteMode', "NATIVE"
}
}
} |
I had almost your settings, but in a comment: #org.gradle.jvmargs=-Xmx4G -XX:+HeapDumpOnOutOfMemoryError Our deveops person recommended to not specify them:
But I'll uncomment it and try again |
Ok, I found the config to enable these options: tasks.configureEach { theTask ->
def taskName = theTask.name.toString()
if (taskName =~ /test.*DebugUnitTest/) {
- theTask.jvmArgs('-ea', '-noverify')
+ theTask.jvmArgs('-ea', '-noverify', '-Xmx4G', '-XX:+HeapDumpOnOutOfMemoryError')
}
} I now have a 2G heap file! I'll check out VisualVM |
Can you search for |
For info, doing this at the end of each test makes the Registries.NATIVE_THEME9_REGISTRY.clear() |
I'll look for activites though |
Possibly related: #5530 |
Thanks for reporting this. Looking at this further, it does seem like the logic that frees themes does not seem to run in Android S: This seems to be the logic for releasing themes now: This ends up calling nativeDestroy. |
Previously, in Android P through R, Robolectric would clean up native themes from the registry when AssetManager.nativeThemeDestroy was called by the ThemeImpl finalizer. However, starting in Android S, AssetManager.nativeThemeDestroy does not exist any more. As a workaround, hook into the AssetManager.releaseTheme method to free the theme from the registry. Longer term we may want to have the theme destruction logic be part of AssetManager.nativeDestroy, where all themes can potentially be freed in one fell swoop. This should fix #6872. Thanks to @calvarez-ov for reporting the issue and helping debug :) PiperOrigin-RevId: 411169531
Previously, in Android P through R, Robolectric would clean up native themes from the registry when AssetManager.nativeThemeDestroy was called by the ThemeImpl finalizer. However, starting in Android S, AssetManager.nativeThemeDestroy does not exist any more. As a workaround, hook into the AssetManager.releaseTheme method to free the theme from the registry. Longer term we may want to have the theme destruction logic be part of AssetManager.nativeDestroy, where all themes can potentially be freed in one fell swoop. This should fix #6872. Thanks to @calvarez-ov for reporting the issue and helping debug :) PiperOrigin-RevId: 411169531
Previously, in Android P through R, Robolectric would clean up native themes from the registry when AssetManager.nativeThemeDestroy was called by the ThemeImpl finalizer. However, starting in Android S, AssetManager.nativeThemeDestroy does not exist any more. As a workaround, hook into the AssetManager.releaseTheme method to free the theme from the registry. Longer term we may want to have the theme destruction logic be part of AssetManager.nativeDestroy, where all themes can potentially be freed in one fell swoop. This should fix #6872. Thanks to @calvarez-ov for reporting the issue and helping debug :) PiperOrigin-RevId: 411169531
Previously, in Android P through R, Robolectric would clean up native themes from the registry when AssetManager.nativeThemeDestroy was called by the ThemeImpl finalizer. However, starting in Android S, AssetManager.nativeThemeDestroy does not exist any more. As a workaround, hook into the AssetManager.releaseTheme method to free the theme from the registry. Longer term we may want to have the theme destruction logic be part of AssetManager.nativeDestroy, where all themes can potentially be freed in one fell swoop. This should fix #6872. Thanks to @calvarez-ov for reporting the issue and helping debug :) PiperOrigin-RevId: 411169531
Previously, in Android P through R, Robolectric would clean up native themes from the registry when AssetManager.nativeThemeDestroy was called by the ThemeImpl finalizer. However, starting in Android S, AssetManager.nativeThemeDestroy does not exist any more. As a workaround, hook into the AssetManager.releaseTheme method to free the theme from the registry. Longer term we may want to have the theme destruction logic be part of AssetManager.nativeDestroy, where all themes can potentially be freed in one fell swoop. This should fix #6872. Thanks to @calvarez-ov for reporting the issue and helping debug :) PiperOrigin-RevId: 411169531
Just pushed 4.7.2 which should hopefully contain a fix for this issue. Reopening for now. @calvarez-ov when you get a chance can you check if it worked? |
Yes, it works! I updated to Thanks so much! 🙏 (I'm calvarez-ov's evil twin) |
Description
We had issue #2584.
We had this workaround for that issue, on every test tearDown:
With robolectric 4.7.1, if we set
sdk=31
inrobolectric.properties
, this workaround causes reflection exceptions when running tests.I removed the workaround, and I have
OutOfMemoryError
s once again.Steps to Reproduce
See #2584
Robolectric & Android Version
sdk
: 31Note: with robolectric 4.7.1, if stay withsdk
of30
and keep the workaround, there aren'tOutOfMemoryError
sNot so sure about this statement. I need to double check.
The text was updated successfully, but these errors were encountered: