Author Topic: OutOfMemory Exception When Building  (Read 3829 times)

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
OutOfMemory Exception When Building
« on: 2012-07-01, 10:58:32 PM »
There isn't much to say really. When I try to compile my project I get an OutOfMemory Exception.

Monitoring my Performance: 4GB of Memory, when building my project and it reaches 2.03GB and claims to be out of Memory.

Is there a way to break up an SGDK2 Project in smaller parts? I've checked on the internet for this and a large amount of people have this error, they usually claim to either 'hack' visual studio or break apart their solution into smaller pieces.

This puts a major stilt on my plans. I'm only finished a very small part of what I need to be, a very large game. I really can't afford for this to happen, especially when my Physical Memory Usage monitor is CLEARLY telling me that there's still more than enough memory free.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2738
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: OutOfMemory Exception When Building
« Reply #1 on: 2012-07-02, 01:59:49 AM »
I assume when you get this error, all the source code is already generated, and SGDK2 is trying to build it. It would help to know if Visual Studio (Visual C# Express) gives you the same error when you tell it to use the generated project file and build the same project. Does it provide any better information or suggestions about the circumstances?

Perhaps it doesn't like having so much data embedded in the EXE. What are the largest pieces going into the EXE. Would it be possible to do a trial compile without those embedded (in Visual Studio, select the file, and in the properties window (F4) change "Embedded Resource" to something else)? If that resolves the problem, maybe you need to make more of your resources not embedded.

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: OutOfMemory Exception When Building
« Reply #2 on: 2012-07-02, 10:16:37 AM »
I took your advice in part of it's entirety Bluemonkmn, tracked down the largest pieces that I wasn't actually using (Ridiculously large maps that I never actually allowed the player to visit) and deleted them.

The issue was temporarily allayed (And actually I've cut the compiling time from 3 minutes to compile to 20 seconds  ;D) by deleting those maps. (Some of which had reached 14MB, and I had no clue why)

I had developed some bad habits in SGDK2 from the past, such as creating maps with an absurd amount of space that I would never actually use... Then again, optimization was the last thing on my mind when I was 12. :D


So after comparing my proudest map (The one I've been working on for weeks now and contains the First Area, which is SURPRISINGLY only 111KB) to the largest one (Before I started optimizing my maps so its 14.2MB) I found that if I optimize my maps, I can actually hold a large amount of maps and hopefully never run into this issue again. 14,000/111 = 126 Maps. That's an appropriate amount of maps for an ORPG.


But.... I will, eventually.... run into this issue again soon enough, but from the looks of things, as long as I continue to optimize my maps- (I've started to use pixel offsets and small size in tile values for maps ever since I transitioned to 3D because I'd be asking SGDK2 to render up to 160 3D Cubes each second without some lag, something my computer seems to just fail at) and I'm sticking with 1 byte per tile because I figure having 2 bytes is like having 256 layers of what I'm really trying to use... These workarounds can only slow down the main issue for only so long though...This limitation is scaring me even more than the other one that I've encountered earlier...

I found an article that gave me a way to boost VisualStudio's available memory from 2MB to 3MB, because it seems that 2MB is the limit. I'm shelving it as a last resort though... It might cause my computer to become unresponsive..


v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: OutOfMemory Exception When Building
« Reply #3 on: 2012-07-03, 11:22:15 PM »
Yeah, I'm rarely receiving it now. Amazing how much space one map can take. If it starts to become a large issue again I'll revive this thread I guess.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2738
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: OutOfMemory Exception When Building
« Reply #4 on: 2012-07-04, 04:29:50 AM »
You mean you're still getting Out Of Memory exceptions occasionally? Is it only through SGDK2 or also through C#?

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: OutOfMemory Exception When Building
« Reply #5 on: 2012-07-04, 04:44:13 PM »
Still, but once in a blue moon. I've tried building in Visual Studio and I don't get it though. Primarily because it's hard to replicate. It happens rarely but randomly..... (Which makes no sense but hey Rarely is better than The Majority of the Time)

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: OutOfMemory Exception When Building
« Reply #6 on: 2013-04-05, 05:49:26 PM »
WOW, never received this nasty looking one before: Pic # 1

EDIT: Pic # 2, Rebuilt, and at least the project that was saved wasn't corrupted this time :D

I was afraid that this would happen as my project developed.

Maybe my project is just meant to be a proof of concept.
« Last Edit: 2013-04-05, 05:56:22 PM by Galaxy »

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2738
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: OutOfMemory Exception When Building
« Reply #7 on: 2013-04-06, 05:42:21 AM »
You were afraid that you would get a generic error in GDI+ as your project developed? That would be remarkable foresight! ;)

I wouldn't be too concerned about this one-time fluke. There's no evidence your project is permanently stuck with this error, right?

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: OutOfMemory Exception When Building
« Reply #8 on: 2013-04-06, 11:25:02 AM »
It went on for about 7 minutes and hasn't come back!

The second copy, 99o, didn't actually save even though it said that it saved.

Either way, I had a backup that was more recent!

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2738
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: OutOfMemory Exception When Building
« Reply #9 on: 2013-04-08, 04:30:07 AM »
I know it's beside the point now, but are you sure you looked in C:\Users\David Thomas\Documents\Paradigm for the second copy? I don't know how it would display that message without successfully saving the project.

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: OutOfMemory Exception When Building
« Reply #10 on: 2013-04-08, 12:39:09 PM »
I know it's beside the point now, but are you sure you looked in C:\Users\David Thomas\Documents\Paradigm for the second copy? I don't know how it would display that message without successfully saving the project.

Pic2 was from my second attempt, it wasn't corrupted, but by not saving, I mean that it's almost as if it went backwards- it was less recent than my less recent backup, as if it wasn't saved from recent data.

Either way, it loads fine now, it's just not the most recent project ;)