Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.98a is out! (03/27/25)

Pages: 1 [2] 3

Author Topic: Unable to load certain saves  (Read 16588 times)

XpanD

  • Captain
  • ****
  • Posts: 380
    • View Profile
Re: Unable to load certain saves
« Reply #15 on: February 06, 2014, 11:40:10 AM »

Just had my first issue. I was flying around the Tasserus system (Uomoz' mod), decided to load an older save as I didn't really find anything of interest but wasted a bunch of supplies to get around. Game froze up, window went gray and nothing happened for the 20 minutes I left it. Eventually had to force-close it. Not much out of the ordinary in the log file that I can see, just the following:

Spoiler
26170441 [Thread-5] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Loading ..\\saves/save_XpanD31_1440361061990470780...
[close]

No "finished loading" message or anything else after that, as it never loaded. I reloaded the game after this happened, loaded my save game, and it started right into it with no delays whatsoever. I do seem to be back a bit further than I last remember saving at, so... did it recover a backup of sorts? The game had been running for about 10 hours in a row (mostly going in the background), if that matters any.
« Last Edit: February 06, 2014, 11:42:10 AM by XpanD »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 26092
    • View Profile
Re: Unable to load certain saves
« Reply #16 on: February 06, 2014, 12:32:19 PM »

No "finished loading" message or anything else after that, as it never loaded. I reloaded the game after this happened, loaded my save game, and it started right into it with no delays whatsoever. I do seem to be back a bit further than I last remember saving at, so... did it recover a backup of sorts? The game had been running for about 10 hours in a row (mostly going in the background), if that matters any.

Hmm, no, it doesn't recover backups automatically - that save should be exactly where you saved last. I don't actually see any way for how that could not be the case :)

As for running the game for 10 hours in a row - that could be an issue, yeah. There's a memory leak in the title screen (now fixed) - nothing that would really matter in "normal" usage, but if you leave the game up for a while and it hangs out in the title screen, you could see problems.
Logged

XpanD

  • Captain
  • ****
  • Posts: 380
    • View Profile
Re: Unable to load certain saves
« Reply #17 on: February 06, 2014, 01:24:42 PM »

Not entirely sure about the possible setback, so don't worry about that one - probably just thought I saved a bit later than I did. As for the title screen thing, the game was paused in-travel through most of those 10 hours. I'll keep an eye on the savegame stuff, will post if anything bad happens, or abstain if everything is smooth sailing from here. :P
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 26092
    • View Profile
Re: Unable to load certain saves
« Reply #18 on: February 06, 2014, 01:54:20 PM »

Alright, cool.
Logged

XpanD

  • Captain
  • ****
  • Posts: 380
    • View Profile
Re: Unable to load certain saves
« Reply #19 on: February 06, 2014, 02:28:34 PM »

Bingo! Was trying something in a clean savegame (latest Uomoz's Sector + Lazylib) for a bit, got this after about 30 minutes:

Spoiler
9858073 [Thread-5] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Loading ..\\saves/save_XpanD32_3198409979355169368...
9904352 [Thread-5] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Error loading
9904811 [Thread-5] ERROR com.fs.starfarer.campaign.save.CampaignGameManager  - GC overhead limit exceeded
java.lang.OutOfMemoryError: GC overhead limit exceeded
   at com.thoughtworks.xstream.io.path.PathTracker.peekElement(PathTracker.java:131)
   at com.thoughtworks.xstream.io.path.PathTracker.getPath(PathTracker.java:169)
   at com.thoughtworks.xstream.core.ReferenceByXPathUnmarshaller.getCurrentReferenceK ey(ReferenceByXPathUnmarshaller.java:41)
   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:63)
   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unma rshallField(AbstractReflectionConverter.java:355)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUn marshal(AbstractReflectionConverter.java:306)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unma rshal(AbstractReflectionConverter.java:234)
   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
   at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.rea dItem(AbstractCollectionConverter.java:71)
   at com.thoughtworks.xstream.converters.collections.CollectionConverter.addCurrentE lementToCollection(CollectionConverter.java:79)
   at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCol lection(CollectionConverter.java:72)
   at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCol lection(CollectionConverter.java:66)
   at com.thoughtworks.xstream.converters.collections.CollectionConverter.unmarshal(CollectionConverter.java:61)
   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unma rshallField(AbstractReflectionConverter.java:355)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUn marshal(AbstractReflectionConverter.java:306)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unma rshal(AbstractReflectionConverter.java:234)
   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unma rshallField(AbstractReflectionConverter.java:355)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUn marshal(AbstractReflectionConverter.java:306)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unma rshal(AbstractReflectionConverter.java:234)
   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
[close]

Reloading the game allowed a clean load off of the same savegame (which I have copied into a .zip, if need be). This "session" ran for about 3-4 hours total, during which I was only in the title screen to load my saves a few times and to make a new character once. Hope this helps any!


(vmparams file used follows, for reference)
Spoiler
-server -XX:CompilerThreadPriority=1 -XX:+CompilerThreadHintNoPreempt -Djava.library.path=native\\windows -Xms1024m -Xmx1024m -classpath janino.jar;commons-compiler.jar;commons-compiler-jdk.jar;starfarer.api.jar;starfarer_obf.jar;jogg-0.0.7.jar;jorbis-0.0.15.jar;json.jar;lwjgl.jar;jinput.jar;log4j-1.2.9.jar;lwjgl_util.jar;fs.sound_obf.jar;fs.common_obf.jar;xstream-1.4.2.jar -Dcom.fs.starfarer.settings.paths.saves=..\\saves -Dcom.fs.starfarer.settings.paths.screenshots=..\\screenshots -Dcom.fs.starfarer.settings.paths.mods=..\\mods -Dcom.fs.starfarer.settings.paths.logs=. com.fs.starfarer.StarfarerLauncher
[close]
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 26092
    • View Profile
Re: Unable to load certain saves
« Reply #20 on: February 06, 2014, 03:29:11 PM »

Hmm. What exactly were you doing? Knowing the specific sequence of loading/saving/entering combat (if any) could help here.


(Also: have you tried setting the memory to 1500 or so?)

Logged

XpanD

  • Captain
  • ****
  • Posts: 380
    • View Profile
Re: Unable to load certain saves
« Reply #21 on: February 07, 2014, 01:58:22 AM »

I was flying around hyperspace, seeing which system I'd explore next. Before that, I was picking fights in Askonia, trying to get enough fuel and supplies to be able to travel for a while. I only have 4 lightly armed ships in the fleet, if that matters any. I'll change the allocation to 1536 and play around for a bit again.

EDIT: Got another freeze after jumping around hyperspace a lot, 20 or so minutes after last starting the game itself. I had a save near the Askonia gates in hyperspace, and spent 40 minutes (I restarted the game inbetween) loading that save over and over (using F9) and flying into a different system every time. Eventually settled on one system that looked like fun, saved (F5) in there, flew to a nearby station, reloaded (F9), flew to another station, tried to reload (F9), had the game freeze entirely at around 55%. I'll keep it running in the background for an hour or so, hoping it unfreezes.

Extra info: Very little combat during this time (if any!), just lots and lots of reloading to see what every system had to offer before finding one to settle in. This happened in the Mirage system. I had a 1536m allocation set up.

EDIT #2: Yes! 10 minutes later, the game unfroze and this happened:
Spoiler
1632496 [Thread-5] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Loading ..\\saves/save_XpanD32_3198409979355169368...
2240630 [Thread-5] INFO  com.fs.starfarer.campaign.save.CampaignGameManager  - Error loading
2240630 [Thread-5] ERROR com.fs.starfarer.campaign.save.CampaignGameManager  - Java heap space
java.lang.OutOfMemoryError: Java heap space
   at java.lang.StringBuffer.toString(Unknown Source)
   at com.thoughtworks.xstream.io.path.PathTracker.peekElement(PathTracker.java:133)
   at com.thoughtworks.xstream.io.path.PathTracker.getPath(PathTracker.java:169)
   at com.thoughtworks.xstream.core.ReferenceByXPathUnmarshaller.getCurrentReferenceK ey(ReferenceByXPathUnmarshaller.java:41)
   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:63)
   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unma rshallField(AbstractReflectionConverter.java:355)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUn marshal(AbstractReflectionConverter.java:306)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unma rshal(AbstractReflectionConverter.java:234)
   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
   at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.rea dItem(AbstractCollectionConverter.java:71)
   at com.thoughtworks.xstream.converters.collections.CollectionConverter.addCurrentE lementToCollection(CollectionConverter.java:79)
   at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCol lection(CollectionConverter.java:72)
   at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCol lection(CollectionConverter.java:66)
   at com.thoughtworks.xstream.converters.collections.CollectionConverter.unmarshal(CollectionConverter.java:61)
   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unma rshallField(AbstractReflectionConverter.java:355)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUn marshal(AbstractReflectionConverter.java:306)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unma rshal(AbstractReflectionConverter.java:234)
   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
   at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unma rshallField(AbstractReflectionConverter.java:355)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUn marshal(AbstractReflectionConverter.java:306)
   at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unma rshal(AbstractReflectionConverter.java:234)
   at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
   at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
[close]

I'll keep it open in the background, so let me know if you want me to try anything specific in this session. Windows apparently really wanted a reboot, sorry!
« Last Edit: February 07, 2014, 10:45:50 AM by XpanD »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 26092
    • View Profile
Re: Unable to load certain saves
« Reply #22 on: February 07, 2014, 12:41:56 PM »

Thanks for giving it another go! Given that a bunch of save/loading in a row seems to trigger this, I'm again inclined to suspect it being a mod-specific issue. It's pretty easy to accidentally hang on to a reference somewhere that would cause a memory leak on game load.

Not saying it *couldn't* be a core issue, but I did test this specific scenario (saving/loading a lot) a fair bit.
Logged

Uomoz

  • Admiral
  • *****
  • Posts: 2663
  • 'womo'dz
    • View Profile
Re: Unable to load certain saves
« Reply #23 on: February 07, 2014, 06:05:15 PM »

Hey there Alex! Is there anything I could do to detect stuff like that? I didn't really had any problems loading and saving on my side, and I don't really know where to start searching for a leak.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 26092
    • View Profile
Re: Unable to load certain saves
« Reply #24 on: February 07, 2014, 06:45:22 PM »

It's... a bit involved. Just gave it a whirl (with some good results). On a high level, what you want to do is connect to the game using some kind of Java profiling tool, do whatever you suspect causes a leak, and then take a memory snapshot (called a "heap dump") to see what's leaking and where.

Edit (8/3/2020): you can download jvisualvm here.

One way to do this is:
1) Run jvisualvm.exe (found in the bin directory of a JDK installation)
2) Connect to StarfarerLauncher - now you have all sorts of neat real-time data available, including memory and processor usage.
3) In the game, do whatever it is you think may cause a memory leak (in this case, just reload a save)
4) In jvisualvm, right-click on the application and select "Heap Dump"
5) Open up the heap dump in the tab on the right - this is going to have the contents of the memory at the time the dump was taken
6) Sort the heap dump by the "classes" field, look for com.fs.stafarer.campaign.CampaignEngine
7) If the "Instances" count is more than 1, you've got a memory leak (there are other ways to have memory leaks, of course, but when you're leaking whole copies of the game world, that's generally a problem)
8) Right-click on CampaignEngine, select "show in instances view"
9) There should be a couple of those visible in the "Instances" tab (#1, #2, etc). The last one is generally the real/current one, the other ones are leaks
10) Select one of those, then under "References", right-click on "this" and select "Show nearest GC root".
11) This is where it gets a bit confusing. It'll show you the thing that's holding a reference to the CampaignEngine instance and is preventing it from being garbage-collected, but it generally won't be something immediately recognizable. Go up the tree until you see something familiar (i.e. a class that's part of the mod), and see what field name is pointed out there. That's the likely source of the leak.

So, the end result of this process, for me, pointed to TheNomadsCloningVats hullmod, but the field was "memo", which wasn't present in the class. Looking in its base class - BaseFleetEffectHullMod - yielded this:

Code: java
public abstract class BaseFleetEffectHullMod extends BaseHullMod
{
// possible long-term memory leak
private Hashtable memo = new Hashtable();

The comment's not mine, and yeah, it's a memory leak alright, for any hullmod using that base class. HullModEffects get instantiated once per application run, and shouldn't hold on to any data long term. You might be wondering why holding on to a fleet member inside "memo" is causing the whole CampaignEngine to not be garbage-collected - it's because there are internal references to the engine a few levels down from stuff in the fleet.

Important note: this does not mean this is the only memory leak. If I had to guess, I would guess there are others, since this type of mistake is easy to make (and it can be hard to know you're making it, for example it's not 100% clear exactly when HullModEffects get instantiated). So, basically, the process for hunting this type of thing down is doing these steps and fixing the problems one at a time until the instance count for CampaignEngine stays at 1 when you do the sequence of steps that used to cause problems.

Let me know if the above makes any sense, and if you've got any questions about it! It might seem intimidating, weighing in at 11 steps and all, but it's actually really fast to step through once you've got the hang of it - it literally only took me a minute or two, once I was all set up with the latest versions of the mods.
« Last Edit: August 03, 2020, 09:15:44 AM by Alex »
Logged

Uomoz

  • Admiral
  • *****
  • Posts: 2663
  • 'womo'dz
    • View Profile
Re: Unable to load certain saves
« Reply #25 on: February 08, 2014, 04:27:17 AM »

Thanks for the lengthy explanation! Now, if you please, I need to squash some leaks...
Logged

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: Unable to load certain saves
« Reply #26 on: February 08, 2014, 04:40:47 AM »

....
One way to do this is:
1) Run jvisualvm.exe (found in the bin directory of a JDK installation)
2) Connect to StarfarerLauncher - now you have all sorts of neat real-time data available, including memory and processor usage.
3) In the game, do whatever it is you think may cause a memory leak (in this case, just reload a save)
...

That post is quite relevant to all modders and worthy of official starsector documentation or sticky "if you have a memory leak, try this first"
Logged

Uomoz

  • Admiral
  • *****
  • Posts: 2663
  • 'womo'dz
    • View Profile
Re: Unable to load certain saves
« Reply #27 on: February 08, 2014, 03:34:53 PM »

Thanks for the lengthy explanation! Now, if you please, I need to squash some leaks...

Seems like nomads were the only "culprits" of the leak, given it's not happening when I exclude them from UsS.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 26092
    • View Profile
Re: Unable to load certain saves
« Reply #28 on: February 08, 2014, 04:44:06 PM »

That post is quite relevant to all modders and worthy of official starsector documentation or sticky "if you have a memory leak, try this first"

Hmm, yeah, I'll see if I can find some time to pretty that up and put it there.

Thanks for the lengthy explanation! Now, if you please, I need to squash some leaks...

Seems like nomads were the only "culprits" of the leak, given it's not happening when I exclude them from UsS.

Nice! So you were able to reproduce and confirm it using jvisualvm? Was wondering if the steps I wrote out were too hand-wavy or actually enough to go on.
Logged

Uomoz

  • Admiral
  • *****
  • Posts: 2663
  • 'womo'dz
    • View Profile
Re: Unable to load certain saves
« Reply #29 on: February 08, 2014, 05:01:43 PM »

That was super well written.
I could replicate it on my system and verify that didn't happen again (only 1 instance of CampaignEngine!).
Logged
Pages: 1 [2] 3