Skip to content
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

test: fix OutOfMemoryError: Java heap space #15532

Merged
merged 1 commit into from
Feb 16, 2024

Conversation

david-allison
Copy link
Member

@david-allison david-allison commented Feb 16, 2024

on macos:

at com.ichi2.anki.dialogs.CreateDeckDialogTest.setUp(CreateDeckDialogTest.kt:52)

Caused by:
java.lang.OutOfMemoryError: Java heap space
    at java.desktop/java.awt.image.DataBufferInt.<init>(DataBufferInt.java:77)
    at java.desktop/java.awt.image.Raster.createPackedRaster(Raster.java:538)
    at java.desktop/java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1032)
    at java.desktop/java.awt.image.BufferedImage.<init>(BufferedImage.java:333)
    at org.robolectric.shadows.ShadowBitmapFactory.create(ShadowBitmapFactory.java:287)
    at org.robolectric.shadows.ShadowBitmapFactory.decodeStream(ShadowBitmapFactory.java:189)
    at org.robolectric.shadows.ShadowBitmapFactory.decodeStream(ShadowBitmapFactory.java:153)

on macos:

```
at com.ichi2.anki.dialogs.CreateDeckDialogTest.setUp(CreateDeckDialogTest.kt:52)

Caused by:
java.lang.OutOfMemoryError: Java heap space
    at java.desktop/java.awt.image.DataBufferInt.<init>(DataBufferInt.java:77)
    at java.desktop/java.awt.image.Raster.createPackedRaster(Raster.java:538)
    at java.desktop/java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1032)
    at java.desktop/java.awt.image.BufferedImage.<init>(BufferedImage.java:333)
    at org.robolectric.shadows.ShadowBitmapFactory.create(ShadowBitmapFactory.java:287)
    at org.robolectric.shadows.ShadowBitmapFactory.decodeStream(ShadowBitmapFactory.java:189)
    at org.robolectric.shadows.ShadowBitmapFactory.decodeStream(ShadowBitmapFactory.java:153)
```

https://redirect.github.com/ankidroid/Anki-Android/pull/15520#issuecomment-1948416566
@david-allison david-allison added the Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) label Feb 16, 2024
@david-allison david-allison merged commit 1113858 into ankidroid:main Feb 16, 2024
10 checks passed
@david-allison david-allison deleted the tests-fix-oom branch February 16, 2024 14:47
@github-actions github-actions bot added this to the 2.17 release milestone Feb 16, 2024
@github-actions github-actions bot removed the Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) label Feb 16, 2024
@@ -30,6 +30,7 @@ import com.ichi2.anki.dialogs.CreateDeckDialog.DeckDialogType
import com.ichi2.anki.dialogs.utils.input
import com.ichi2.libanki.DeckId
import com.ichi2.utils.positiveButton
import okhttp3.internal.closeQuietly
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this correct? an internal import, but the method call below is on the activityScenario member

Copy link
Member Author

@david-allison david-allison Feb 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an extension to closeable which ignores checked exceptions

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/** Closes this, ignoring any checked exceptions. */
fun Closeable.closeQuietly() {
  try {
    close()
  } catch (rethrown: RuntimeException) {
    throw rethrown
  } catch (_: Exception) {
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants