yairm210 / Unciv

Open-source Android/Desktop remake of Civ V
Mozilla Public License 2.0
8.4k stars 1.56k forks source link

Out of memory when creating new game with Alpha Frontier #9745

Closed Lwaht closed 1 year ago

Lwaht commented 1 year ago

Platform: Android Version: 4.7.6-patch2 (Build 888) Rulesets: [Policy mod, Pix5 Tileset, Civ V - Vanilla, AbsoluteUnitsXL, Extra Buildings, Civ Army Color Style Sheet, Alpha Frontier, Future Expansion, CS Overhaul, Civ6 Stat Icons, Civ V - Gods & Kings, Soviet Union, Fantasia, Better Units and Natural Wonders] Last Screen: com.unciv.ui.screens.newgamescreen.NewGameScreen


Device Model: SM-A146P API Level: 33


Message:

java.lang.OutOfMemoryError: Failed to allocate a 24 byte allocation with 5131372 free bytes and 5011KB until OOM, target footprint 536870912, growth limit 536870912; giving up on allocation because <1% of heap free after GC.
    at kotlin.collections.CollectionsKt__CollectionsKt.arrayListOf(Collections.kt:114)
    at com.unciv.models.ruleset.unique.UniqueMap.addUnique(Unique.kt:367)
    at com.unciv.models.ruleset.unique.UniqueMap.addUniques(Unique.kt:372)
    at com.unciv.logic.map.tile.Tile.setTerrainFeatures(Tile.kt:835)
    at com.unciv.logic.map.tile.Tile.setTerrainTransients(Tile.kt:748)
    at com.unciv.logic.map.TileMap.setTransients(TileMap.kt:453)
    at com.unciv.logic.map.TileMap.setTransients$default(TileMap.kt:416)
    at com.unciv.logic.map.TileMap.<init>(TileMap.kt:105)
    at com.unciv.logic.map.mapgenerator.MapGenerator.generateMap(MapGenerator.kt:99)
    at com.unciv.logic.GameStarter$startNewGame$3.invoke(GameStarter.kt:72)
    at com.unciv.logic.GameStarter$startNewGame$3.invoke(GameStarter.kt:68)
    at com.unciv.logic.GameStarter.runAndMeasure(GameStarter.kt:152)
    at com.unciv.logic.GameStarter.startNewGame(GameStarter.kt:68)
    at com.unciv.ui.screens.newgamescreen.NewGameScreen$startNewGame$2.invokeSuspend(NewGameScreen.kt:307)
    at com.unciv.ui.screens.newgamescreen.NewGameScreen$startNewGame$2.invoke(Unknown Source:8)
    at com.unciv.ui.screens.newgamescreen.NewGameScreen$startNewGame$2.invoke(Unknown Source:4)
    at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
    at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:264)
    at com.unciv.ui.screens.newgamescreen.NewGameScreen.startNewGame(NewGameScreen.kt:298)
    at com.unciv.ui.screens.newgamescreen.NewGameScreen.access$startNewGame(NewGameScreen.kt:53)
    at com.unciv.ui.screens.newgamescreen.NewGameScreen$onStartGameClicked$7.invokeSuspend(NewGameScreen.kt:232)
    at com.unciv.ui.screens.newgamescreen.NewGameScreen$onStartGameClicked$7.invoke(Unknown Source:8)
    at com.unciv.ui.screens.newgamescreen.NewGameScreen$onStartGameClicked$7.invoke(Unknown Source:4)
    at com.unciv.utils.ConcurrencyKt$launchCrashHandling$1.invokeSuspend(Concurrency.kt:87)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at com.unciv.utils.CrashHandlingDispatcher$dispatch$1.invoke(Concurrency.kt:173)
    at com.unciv.utils.CrashHandlingDispatcher$dispatch$1.invoke(Concurrency.kt:173)
    at com.unciv.ui.crashhandling.CrashHandlingExtensionsKt$wrapCrashHandling$1.invoke(CrashHandlingExtensions.kt:17)
    at com.unciv.ui.crashhandling.CrashHandlingExtensionsKt$wrapCrashHandlingUnit$1.invoke(CrashHandlingExtensions.kt:33)
    at com.unciv.ui.crashhandling.CrashHandlingExtensionsKt$wrapCrashHandlingUnit$1.invoke(CrashHandlingExtensions.kt:33)
    at com.unciv.utils.CrashHandlingDispatcher.dispatch$lambda$0(Concurrency.kt:173)
    at com.unciv.utils.CrashHandlingDispatcher.$r8$lambda$GFMOlD6QMgmLfgwAvPAW33Ob6HE(Unknown Source:0)
    at com.unciv.utils.CrashHandlingDispatcher$$ExternalSyntheticLambda0.run(Unknown Source:2)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
    at java.lang.Thread.run(Thread.java:1012)
SomeTroglodyte commented 1 year ago

That's simply out of memory I'd say. A Galaxy A14 5G has at least 4G, but that's no guarantee the OS allows a Java VM enough heap. Try smaller a map - what size did you choose?

Lwaht commented 1 year ago

Ok, i'll try it. Thanks for fast respond

Pada tanggal Rab, 5 Jul 2023 2.01 PM, SomeTroglodyte < @.***> menulis:

That's simply out of memory I'd say. A Galaxy A14 5G has at least 4G, but that's no guarantee the OS allows a Java VM enough heap. Try smaller a map

  • what size did you choose?

— Reply to this email directly, view it on GitHub https://github.com/yairm210/Unciv/issues/9745#issuecomment-1621149447, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6TRNHACZ4GJXWZ4E2VO3VTXOUGNJANCNFSM6AAAAAAZ6MV3SY . You are receiving this because you authored the thread.Message ID: @.***>

SomeTroglodyte commented 1 year ago

No, really what map size exactly? If you chose custom 300x200 I'd not bother looking farther. But if you chose predefined "Large", that would be worth investigating.

Lwaht commented 1 year ago

I choose medium, but in G&K ruleset it worked, sometimes in Vanilla also not worked Sorry i can send the screen record

Pada tanggal Rab, 5 Jul 2023 4.17 PM, SomeTroglodyte < @.***> menulis:

No, really what map size exactly? If you chose custom 300x200 I'd not bother looking farther. But if you chose predefined "Large", that would be worth investigating.

— Reply to this email directly, view it on GitHub https://github.com/yairm210/Unciv/issues/9745#issuecomment-1621358175, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6TRNHEGJNW4YKV4QRH6WCDXOUWL5ANCNFSM6AAAAAAZ6MV3SY . You are receiving this because you modified the open/close state.Message ID: @.***>

SomeTroglodyte commented 1 year ago

Well, that's curious. Alpha Frontier comes with a lot of textures, but that should have no relevance for the specific step mentioned in the stack trace. That's internal data, not UI graphics. Even if AF comes with a lot more tile-bound Uniques than vanilla, shouldn't go into the GB range... Or so I would guess.

Anyway, I am sure that cannot be debugged as desktop, so it would be a little harder to debug - and possibly doing so on a virtual device, which I haven't got ready for 'roid 13, wouldn't reproduce either, 'cuz OEM specific OS tweaks...

Lwaht commented 1 year ago

Thanks for the explanation.

Pada tanggal Rab, 5 Jul 2023 5.03 PM, SomeTroglodyte < @.***> menulis:

Well, that's curious. Alpha Frontier comes with a lot of textures, but that should have no relevance for the specific step mentioned in the stack trace. That's internal data, not UI graphics. Even if AF comes with a lot more tile-bound Uniques than vanilla, shouldn't go into the GB range... Or so I would guess.

Anyway, I am sure that cannot be debugged as desktop, so it would be a little harder to debug - and possibly doing so on a virtual device, which I haven't got ready for 'roid 13, wouldn't reproduce either, 'cuz OEM specific OS tweaks...

— Reply to this email directly, view it on GitHub https://github.com/yairm210/Unciv/issues/9745#issuecomment-1621443254, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6TRNHCMQIK2YB56JZCTI23XOU3YXANCNFSM6AAAAAAZ6MV3SY . You are receiving this because you modified the open/close state.Message ID: @.***>

Lwaht commented 1 year ago

https://github.com/yairm210/Unciv/assets/128390812/99b9f64a-8b43-4b34-a4c8-fdd98a88bd97

yairm210 commented 1 year ago

I've been thinking of a way to minimize memory consumption for this exact callstack for a while now

So I'll try to play around with it tomorrow to see if I can get results :D

SomeTroglodyte commented 1 year ago

Another idea - get some of the JVM settings a desktop crash screen would show on top into the 'roid one too. Do we have any idea how Andy sets -Xmx and such?

Lwaht commented 1 year ago

https://github.com/yairm210/Unciv/assets/128390812/d2ca75ad-2bc7-419b-a9fc-c9ef4a3fa60e

It also happend on Fantasia ruleset I don't know if another ruleset like this, so i think you should check it out