Author Topic: Out of memory exception?  (Read 7365 times)

pigpenguin

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 37
Out of memory exception?
« on: January 02, 2011, 04:19:26 PM »
So I have been working on my level slowly but getting towards maybe a version i could release and I added a camera move sequence to the begging so I could show what asteroids I am talking about and now i get an error that goes like: Exception of type 'System.OutOfMemoryException' was thrown

Any one know what this is and or how to fix it?

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Out of memory exception?
« Reply #1 on: January 03, 2011, 01:14:34 AM »
Too much stuff in your map, I'd guess. Try simplifying it.

Or I might be wrong.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Out of memory exception?
« Reply #2 on: January 03, 2011, 02:32:53 AM »
Nope, it's not too much stuff in your map.  I've seen that error before, and solved it without reducing anything.  It's an error in logic of some kind, I believe.

It's a very tricky one to pin down because it generally doesn't give you the line number where the error is.  I think that's because it's more of an error in logic rather than syntax.  Not really sure though.

If you can you PM me the code for your level in its entirety, and I'll have a look for you.  :>

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Out of memory exception?
« Reply #3 on: January 03, 2011, 03:19:51 AM »
Lack of coroutine.yield?

Not relinquishing control of a loop could have that effect. (And it's a pretty easy mistake to make as a new coder)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Out of memory exception?
« Reply #4 on: January 03, 2011, 04:26:49 AM »
I've had a look at your code.

You've placed one asteroid at coordinates 50000, 0.  That would mean the quad tree would take up approxiamately 2 billion gigabytes of RAM, I think.

50000 is excessive, and is likely the cause of the problem.  If you reduce it to, say, 20000, does it work then?  20000 is still really really far.  If it's still not far enough, try reducing the global min and max speed of seedlings and reducing the radius of your asteroids.  That should make the same distance seem further.

Alex

  • Administrator
  • Ent
  • *****
  • Thank You
  • -Given: 3
  • -Receive: 14
  • Posts: 1,035
Re: Out of memory exception?
« Reply #5 on: January 03, 2011, 05:20:26 AM »
Also consider having the bulk of your level at e.g. -25000, then having your far asteroid at 25000, so that the level is centred.

pigpenguin

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 37
Re: Out of memory exception?
« Reply #6 on: January 03, 2011, 10:26:35 AM »
2 billion gigs of ram.... well that would explain that and yes when i switch to 20000 it works (to be honest an extra 0 slipped its self in :P) but now the set camera target is barley moving it seems to move and hit an invisible wall... is the camera fixed to what is in your range of view?

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Out of memory exception?
« Reply #7 on: January 03, 2011, 10:40:14 AM »
Yes.  Change the coordinates in your camera command to 20000 (or 5000 or whatever the asteroid position is) too.  :>


Also, I just remembered... for some reason, Camera coordinates work in the negative.  If you want the camera to move to an asteroid at coordinates (1000,1500), you need to tell the camera to zoom to (-1000,-1500) if you want it to focus on the asteroid.

Took me a while to figure that one out.  :>

pigpenguin

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 37
Re: Out of memory exception?
« Reply #8 on: January 03, 2011, 12:07:51 PM »
Hmmm thats weird with the negatives but even with them set to negative the camera goes to the right bout .2 of an inch and then goes down until it seems centered round the 0...

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Out of memory exception?
« Reply #9 on: January 03, 2011, 12:28:03 PM »
Have you used the GetAsteroid(1):Reveal(1) command to reveal asteroid ID 1 to player 1?

pigpenguin

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 37
Re: Out of memory exception?
« Reply #10 on: January 03, 2011, 12:40:06 PM »
Ahhhh there would be my mistake so the camera is bound to what the player can see sweet i will plug that bit in and see how it runs :D
*edit* i threw that in and an out of memory exception was thrown :P
*edit edit* :P got rid of the error now the camera is moving to a spot how ever nothing is there its like its invisible (and i tried the SetVisible(faction,bool) and then it just didnt move :/
« Last Edit: January 03, 2011, 12:56:13 PM by pigpenguin »

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Out of memory exception?
« Reply #11 on: January 03, 2011, 01:54:54 PM »
May Alex fixed the camera reverse thing.  Try it with normal coordinates I guess.

pigpenguin

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 37
Re: Out of memory exception?
« Reply #12 on: January 03, 2011, 04:04:10 PM »
haha it does the same things with positive coordinates :P

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Out of memory exception?
« Reply #13 on: January 03, 2011, 04:12:16 PM »
Can you post the code here or PM it to me?  :>

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Out of memory exception?
« Reply #14 on: January 03, 2011, 06:18:18 PM »
Yes, he did fix negative camera stuff. It was in 2.06 or 2.07 iirc.

pigpenguin

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 37
Re: Out of memory exception?
« Reply #15 on: January 04, 2011, 08:14:35 AM »
Hiya sure i will post the code haha sorry school started back up so im gonna be on less
Code: [Select]
-- Reforistization a map bye pigpenguin --

function LevelSetup()

-- Setting Global Values
Globals.G.Asteroids =(0)
Globals.G.EnemyFactionsMin=(0)
Globals.G.EnemyFactionsMax=(1)
SetBackdropColour(13,110,26)

-- Asteroid 0

a = AddAsteroidWithAttribs(0,0, 0.3, 0.3, 0.9)
a.Owner = 1
a. TreeCap = 4
a:SetRadius(550)
a.SendDistance = 2500
a:AddSeedlings(10)
a.Moveable = False
s = a:AddDysonTree()
s:LevelUp()
s:Levelup()
s = a:AddDefenseTree()
s:LevelUp()
s:LevelUp()
s = a:AddDysonTree()
s:LevelUp()
s:LevelUp()
s = a:AddDefenseTree()
s:LevelUp()
s:LevelUp()

--Asteroid 1
a = AddAsteroidWithAttribs(50000,0, 0.9, 0.3, 0.3)
a.Owner = 0
a.Treecap = 100
a:SetRadius(1000)
a.SendDistance = 2500
a.Moveable = False
a:Reveal(1)

--Asteroid 2
a = AddAsteroidWithAttribs(2000,0, 0.7, 0.7, 0.4)
a.Owner=2
a:SetRadius(230)
a.SendDistance = 2500



end

function LevelLogic()

-- Your Mission
Timer = GetGameTime() + 3
while GetGameTime() < Timer do
coroutine.yield()
end

Pause()
MessageBox("We have a problem, to the far east is an asteroid.")
WaitDialog()
SetCameraPositionToAsteroidID(1)
MessageBox("This asteroid used to be used for harvesting. However our enemies have destroyed all the trees on it. Go forth and plant six trees to kick start its production. You have ten minutes to kickstart the regrowth or else the fertility of the asteroid will start to die. Good luck seedlings")
WaitDialog()
Unpause()


-- Win and loose dialogs
gamewon = 0

while gamewon == 0 do
coroutine.yield()
end

if gamewon == 1 then
Pause()
MessageBox("Congratulations you have restarted the growth on that planet. One day it will be a rich forest like it once was.")
WaitDialog()

Quit(True)
end

if gamewon == 2 then
Pause()
MessageBox("You have managed to loose one of the most fertile asteroids in the galaxy. Your failure is most dissapointing.")
WaitDialog()

Quit(False)
end


end

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Out of memory exception?
« Reply #16 on: January 04, 2011, 08:21:30 AM »
Code: [Select]
function LevelSetup()

-- Setting Global Values
Globals.G.Asteroids =(0)
Globals.G.EnemyFactionsMin=(0)
Globals.G.EnemyFactionsMax=(1)
Globals.Asteroids.MinSendDistance=60000
Globals.Asteroids.MaxSendDistance=60000
SetBackdropColour(13,110,26)

-- Asteroid 0

a = AddAsteroidWithAttribs(-25000,0, 0.3, 0.3, 0.9)
a.Owner = 1
a. TreeCap = 4
a:SetRadius(550)
a.SendDistance = 2500
a:AddSeedlings(10)
a.Moveable = False
s = a:AddDysonTree()
s:LevelUp()
s:Levelup()
s = a:AddDefenseTree()
s:LevelUp()
s:LevelUp()
s = a:AddDysonTree()
s:LevelUp()
s:LevelUp()
s = a:AddDefenseTree()
s:LevelUp()
s:LevelUp()

--Asteroid 1
a = AddAsteroidWithAttribs(25000,0, 0.9, 0.3, 0.3)
a.Owner = 0
a.Treecap = 100
a:SetRadius(1000)
a.SendDistance = 2500
a.Moveable = False
a:Reveal(1)

--Asteroid 2
a = AddAsteroidWithAttribs(-23000,0, 0.7, 0.7, 0.4)
a.Owner=2
a:SetRadius(230)
a.SendDistance = 2500



end


Try this in place of your existing Function LevelSetup().

Note that the game will try to auto-adjust the send distances so that all asteroids are within reach of one another.
If you wish to force them to not be within range, declare the send distances in function LevelLogic() instead.

pigpenguin

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 37
Re: Out of memory exception?
« Reply #17 on: January 04, 2011, 08:31:11 AM »
Weird now the camera doesnt move  :-\

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Out of memory exception?
« Reply #18 on: January 04, 2011, 09:28:47 AM »
Right, the reason it jumps back to the starting asteroid is because you need to tell the game the player is allowed to look at the asteroid at the start.  Otherwise it will try to restrict the view.

To do that, make the asteroid to the far east belong to player 1 when you're creating it in LevelSetup().
Then, as soon as LevelLogic starts, change the owner to player 0.

This code works:

Code: [Select]
function LevelSetup()

-- Setting Global Values
Globals.G.Asteroids =(0)
Globals.G.EnemyFactionsMin=(0)
Globals.G.EnemyFactionsMax=(1)
Globals.Asteroids.MinSendDistance=60000
Globals.Asteroids.MaxSendDistance=60000
SetBackdropColour(13,110,26)

-- Asteroid 0

a = AddAsteroidWithAttribs(-25000,0, 0.3, 0.3, 0.9)
a.Owner = 1
a. TreeCap = 4
a:SetRadius(550)
a.SendDistance = 2500
a:AddSeedlings(10)
a.Moveable = False
s = a:AddDysonTree()
s:LevelUp()
s:Levelup()
s = a:AddDefenseTree()
s:LevelUp()
s:LevelUp()
s = a:AddDysonTree()
s:LevelUp()
s:LevelUp()
s = a:AddDefenseTree()
s:LevelUp()
s:LevelUp()

--Asteroid 1 - this is the one to the far east.
a = AddAsteroidWithAttribs(25000,0, 0.9, 0.3, 0.3)
a.Owner = 1
a.Treecap = 100
a:SetRadius(1000)
a.SendDistance = 2500
a.Moveable = False
a:Reveal(1)

--Asteroid 2
a = AddAsteroidWithAttribs(-23000,0, 0.7, 0.7, 0.4)
a.Owner=2
a:SetRadius(230)
a.SendDistance = 2500



end


function LevelLogic()

GetAsteroid(1).owner = 0

-- Your Mission
Timer = GetGameTime() + 3
while GetGameTime() < Timer do
coroutine.yield()
end

Pause()
MessageBox("We have a problem, to the far east is an asteroid.")
WaitDialog()
SetCameraPositionToAsteroidID(1)
MessageBox("This asteroid used to be used for harvesting. However our enemies have destroyed all the trees on it. Go forth and plant six trees to kick start its production. You have ten minutes to kickstart the regrowth or else the fertility of the asteroid will start to die. Good luck seedlings")
WaitDialog()
Unpause()


-- Win and loose dialogs
gamewon = 0

while gamewon == 0 do
coroutine.yield()
end

if gamewon == 1 then
Pause()
MessageBox("Congratulations you have restarted the growth on that planet. One day it will be a rich forest like it once was.")
WaitDialog()

Quit(True)
end

if gamewon == 2 then
Pause()
MessageBox("You have managed to loose one of the most fertile asteroids in the galaxy. Your failure is most dissapointing.")
WaitDialog()

Quit(False)
end


end

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Out of memory exception?
« Reply #19 on: January 04, 2011, 09:30:37 AM »
This map causes Eufloria to use 337 megs of ram, by the way.

That's the hazard of using extremely large coordinates.  It's centred now, so that helps a lot.

Somthing to be aware of.. :>

pigpenguin

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 37
Re: Out of memory exception?
« Reply #20 on: January 04, 2011, 10:01:02 AM »
haha I will try to control my obsevivly big coordinates  ;D

and thanks for the help its awesome :D

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Out of memory exception?
« Reply #21 on: January 04, 2011, 10:05:07 AM »
You're welcome.  :>