Levels loading problems

Hi everyone,

  1. We are facing problem which gets us really mad. We have 5 levels which are built of 15 256x256 background images placed one after another - just like every scroller game. We have 5 levels which are copy of each other - only the textures itself were changed. Now, Unity iPhone crashes every time we want to open one of the levels without reason while playing the game - random level. Anyone noticed anything similar?

  2. What’s the best workflow for the 2D scroller? We are facing real memory problems, specially when level is loading and even we think we’ve optimized everything it uses 16MB at start for simple menu (just like that, without reason) and after level is loaded it’s over 40MB. Seems like menu is still in the memory. Is there any way of forcing memory cleaning?

Thanks in advance.
Szymon Masiak

  1. Check out the crash log and see why it does that.
    You will need to learn how to work with XCode, the debugger and the iPhone instruments if you really want to develop for the iphone and solve problems you will face.

  2. the 16mb aren’t the menu only. That are to a large degree the engine and .NET code that is required to run anything. With Unity Basic, thats about 16MB of memory.

Generally to clean memory after scene switches, add an empty dummy scene that does nothing but load the real scene

  1. The crash log is empty. It’s Unity itself crashing, not the build. With the build we have issues I’ve mentioned in point #2 and yes, we know how to look at the Activity Monitor - what other instruments we should use then?

  2. We are running Unity Advanced - should 16mb be there?

That’s what we are doing - we are adding dummy “loading next scene” scene - empty scene with one game object loading next level.

Any other ideas?

  1. You said unity iphone crashes whenever you open a level while playing the game. That at least to me indicated that you mean the build, because you didn’t say it crashes when you tried to load the scene etc.
    Without knowing significantly more, problems with the editor are hard to impossible for us to help you because crashes of the editor are likely hardware, OS, software interferance or a broken script / 2.5 script that tries to do the same on Unity iPhone (which is Unity 2.1 + .NET 1.1 only)

One of the most important Instruments is the Memory Leak as it gives you an idea when you head the “deadly memory border”.

  1. did you enable stripping and is your main menu scene empty? because the whole scene is beeing loaded when you enter the scene.
    There are mainly 2 sources that are really large memory wise: uncompressed sounds and textures
  1. Yeah, it’s Unity crashing even the scenes are exact copy of each other and it crashes while loading random level, but the build hangs in exactly the same situations and it happens when memory reaches 40MB (activity monitor).

2.By stripping you mean Player Settings set to “Strip ByteCode” or something else?
To be honest we don’t have sound yet and just a few textures. Some are 1024x1024 co maybe that’s taking most of the memory but this is sprite based game with characters on it, so I’m looking for other ways of optimizing it.

Thanks for your effort !

Szymon

That’s interesting, we’ve changed textures sizes and compressed most of them which gave us more 10MB free however the levels are still hanging up randomly. The memory shows 28MB instead of 40 and still hangs.

Could you please be more specific. We need crash log or at least XCode console output and preferably stack-trace to be able to help you with crashes.

You mean the log from crash reporter in the console? There’s nothing. Last input was few weeks ago.
Xcode doesn’t show anything either. All it says it’s that the file was loaded. Nothing more. The Activity Monitor shows memory stopped at level 28MB and processor is jumping between 70 and 90 %.
Is there any other way of tracing it down?