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

Out of Memory (Only 512MB allowed??) #12411

Open
1 task done
xotikorukx opened this issue Nov 4, 2024 · 3 comments
Open
1 task done

Out of Memory (Only 512MB allowed??) #12411

xotikorukx opened this issue Nov 4, 2024 · 3 comments
Labels

Comments

@xotikorukx
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Game Version

4.14.2-patch1

Describe the bug

According to the stack heap, only 512MB of memory is allowed for use?

Is this a design choice, or just a compatibility choice?

I'm not familiar with Java, but C# I am very familiar with, so if this is something I need to eventually look into, I will. It just seems ridiculous that 512MB is a cap with no option (or memory size auto adaption) to increase max allowed (my phone has 12GB!).

For context, I am playing an 80 size map with max Ai (and that's even too small for me!) because I really enjoy putting "grand" in "grand strategy"; and totally nothing like the masochism of playing a few minutes at a time on my phone during breaks waging full scale 3 pushing 4 digit unit wars.

Way off in a foxhole, I know unciv servers are (for the most part) glorified file hosts. If I ever get time to sit down at a computer again, I've thought once or twice about looking into fragmented saves for multi-player games.

Steps to Reproduce

Play 100 turns into an 80 size map wtih max AI on marathon with standard settings.

Screenshots

No response

Link to save file

No response

Operating System

Android

Additional Information

Platform: Android
Version: 4.14.2-patch1 (Build 1,065)
Rulesets: [Civ V - Vanilla, Civ V - Gods & Kings]
Last Screen: com.unciv.ui.screens.worldscreen.WorldScreen


Device Model: SM-S908U1
API Level: 34
System Memory: 11213 MB
Available (used by Kernel): 3270 MB
System Low Memory state: false
Java heap limit: 512 MB
Java heap free: 0 MB


Message:

java.lang.OutOfMemoryError: Failed to allocate a 16 byte allocation with 1779952 free bytes and 1738KB until OOM, target footprint 536870912, growth limit 536870912; giving up on allocation because <1% of heap free after GC.
	at com.badlogic.gdx.scenes.scene2d.Group.<init>(Group.java:41)
	at com.unciv.ui.images.IconCircleGroup.<init>(IconCircleGroup.kt:16)
	at com.unciv.ui.components.extensions.Scene2dExtensionsKt.surroundWithCircle(Scene2dExtensions.kt:117)
	at com.unciv.ui.components.extensions.Scene2dExtensionsKt.surroundWithCircle$default(Scene2dExtensions.kt:111)
	at com.unciv.ui.components.tilegroups.YieldGroup.getIcon(YieldGroup.kt:34)
	at com.unciv.ui.components.tilegroups.YieldGroup.getStatIconsTable(YieldGroup.kt:46)
	at com.unciv.ui.components.tilegroups.YieldGroup.setStats(YieldGroup.kt:28)
	at com.unciv.ui.components.tilegroups.layers.TileLayerMisc.updateYieldIcon(TileLayerMisc.kt:302)
	at com.unciv.ui.components.tilegroups.layers.TileLayerMisc.doUpdate(TileLayerMisc.kt:386)
	at com.unciv.ui.components.tilegroups.layers.TileLayer.update(TileLayer.kt:39)
	at com.unciv.ui.components.tilegroups.TileGroup.update(TileGroup.kt:129)
	at com.unciv.ui.components.tilegroups.WorldTileGroup.update(WorldTileGroup.kt:22)
	at com.unciv.ui.screens.worldscreen.worldmap.WorldMapTileUpdater.updateTiles(WorldMapTileUpdater.kt:32)
	at com.unciv.ui.screens.worldscreen.WorldScreen.update(WorldScreen.kt:404)
	at com.unciv.ui.screens.worldscreen.WorldScreen.render(WorldScreen.kt:729)
	at com.badlogic.gdx.Game.render(Game.java:48)
	at com.unciv.UncivGame.access$render$s2211858(UncivGame.kt:60)
	at com.unciv.UncivGame$wrappedCrashHandlingRender$1.invoke(UncivGame.kt:83)
	at com.unciv.UncivGame$wrappedCrashHandlingRender$1.invoke(UncivGame.kt:83)
	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.UncivGame.render(UncivGame.kt:411)
	at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:505)
	at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1584)
	at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1283)

Save Mods:

[Civ V - Vanilla]

Save Data:

Show Saved Game
No save data: java.lang.OutOfMemoryError: Failed to allocate a 24 byte allocation with 1071184 free bytes and 1046KB until OOM, target footprint 536870912, growth limit 536870912; giving up on allocation because <1% of heap free after GC.
@xotikorukx xotikorukx added the bug label Nov 4, 2024
@yairm210
Copy link
Owner

yairm210 commented Nov 4, 2024

We explicitly set largeHeap to true, which seems to be the maximum we can do - the actual memory allocated is an Android internal setting
I'm not an Android dev myself, and I can't find how to override this seeing, if at all possible 🤔

@xotikorukx
Copy link
Author

xotikorukx commented Nov 4, 2024

Clearly I'm not either or I would've known this.

It looks like the only "great" way to tackle this is multiprocessing, which for a project like this.... Sounds like an astonishingly bad idea.

Second initial thought far from a computer... Chunking? Possibly iterate chunks and render each Chunk before moving onto the next, loading and parsing a small portion of the save file at a time. If I poke around with a c# server at some point it might be manageable to test question mark? I tried decoding a save file to see if the theory holds water, butI'm assuming its a collection of bespoke structs/objects just base64 encoded? Though this just kicks the can down the road unless its integrated whole hog (minecraft style dynamic load/unload)

Sorry, I guess I'm just barfing thoughts out loud that I can't test until I'm back at a desktop pc lmao

@SeventhM
Copy link
Collaborator

https://stackoverflow.com/questions/73262584/how-do-you-go-over-512mb-of-memory-in-an-android-app

As far as I can see:

  1. my phone has 12GB

    This is not really a great argument for most apps. I've seen devices with low amounts of memory and hitting the memory limit on Android is pretty bad (I've seen a device be unable to even open the keyboard). Maybe we can argue we shouldn't set an arbitrary limit, but your device manufacturer absolutely should to make sure your device functions

  2. We can't really control what the limit is to make use of all of your memory, we can only really set largeHeap to true. This limit is in place by your device's manufacturer. And I don't see a good reason for looking for ways to bypass it

  3. For better compatibility across devices, imo better memory efficiency would probably be a better solution regardless, not just constantly increasing the limit, since we aren't doing that much intensive stuff anyways

  4. Pretty sure issues with the memory limit almost exclusively matters on extremely large games, which I'm pretty sure barely functions on desktop anyways. Kinda a low priority thing imo besides general memory optimizations

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

No branches or pull requests

3 participants