Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: matt on Sun 28/12/2008 00:47:32

Title: error: out of memmory: failed to alicate 1600000000 (at PP=6) (fixed)
Post by: matt on Sun 28/12/2008 00:47:32
i just ran my game and this came up.
Title: Re: error: out of memmory: failed to alicate 1600000000 (at PP=6)
Post by: monkey0506 on Sun 28/12/2008 05:18:29
No, no...it said "Failed to Alicante."

Long live the Alicante Goat Societyâ,,¢

But more or less more seriously... := ...if it failed to allocate memory that would mean that you don't have enough memory available on your computer to allow the program to run. Try closing some programs or restarting the computer and see if the issue persists. If it does, throw your computer madly* out the window and go buy that cool laptop that ProgZ was linking to earlier...

*By "madly" I actually mean simultaneously, "angrily" and "like a mad-man."

Failed memory allocation would imply that you either don't have enough physical memory (RAM), you are running to many programs at once for your computer to handle (pr0n), or you have a memory leak (uber-pr0n). Or, any combination of the above. It's kind of like a Choose-Your-Own-Mammary-Failure...only different.

Also you may try running an antivirus, antispyware, antipr0n program to erase virtually everything you've thus far installed. :D
Title: Re: error: out of memmory: failed to alicate 1600000000 (at PP=6)
Post by: Gilbert on Sun 28/12/2008 06:27:34
Hmmm did you make a large array?

Some people may not notice, arrays can suck a huge amount of memory.

Title: Re: error: out of memmory: failed to alicate 1600000000 (at PP=6)
Post by: matt on Sun 28/12/2008 06:40:06
no, i don't use arrays but i used a lot of ints, strings and dynamic sprites
Title: Re: error: out of memmory: failed to alicate 1600000000 (at PP=6)
Post by: Shane 'ProgZmax' Stevens on Sun 28/12/2008 07:55:21
dynamic sprites are something you want to be careful with since they consume memory when created, compared with sprites you've compiled into the game which either will work from the start or not at all.  My guess is you're going a bit overboard with resource creation and need to scale things back a bit or rework your approach.  Hopefully you're releasing the dynamic sprites when they're no longer in use?  It could be something as simple as you creating a memory slot for a dynamic sprite over and over and not releasing it, resulting in a gradual consumption of memory until there isn't any left.  When you're using anything that consumes memory on the fly, you really need to make sure the memory is cleared when you're done with it.
Title: Re: error: out of memmory: failed to alicate 1600000000 (at PP=6)
Post by: Pumaman on Sun 28/12/2008 22:01:10
What did you change in your game before this started happening?

Can you upload a game that demonstrates this problem?
Title: Re: error: out of memmory: failed to alicate 1600000000 (at PP=6)
Post by: matt on Sun 28/12/2008 22:30:32
i can't do that because the game was too big with all the sprites and without it worked.
Title: Re: error: out of memmory: failed to alicate 1600000000 (at PP=6)
Post by: Pumaman on Sun 28/12/2008 22:33:53
Can you please state clearly what you changed before this problem started happening?

Is it still happening or have you solved it somehow?
Title: Re: error: out of memmory: failed to alicate 1600000000 (at PP=6)
Post by: matt on Mon 29/12/2008 00:06:41
i changed my script to open a sprite off the ags sprite chache rather than another outside file. i also put in 180 200*200 spirtes into the editor.
Title: Re: error: out of memmory: failed to alicate 1600000000 (at PP=6)
Post by: Gilbert on Mon 29/12/2008 06:36:46
Can you post that part of script in question here?
Title: Re: error: out of memmory: failed to alicate 1600000000 (at PP=6)
Post by: matt on Mon 29/12/2008 07:39:55
sure:

DynamicSprite* sprite = DynamicSprite.CreateFromExistingSprite(in8+in9);
                if (sprite != null) {
                          int slot = (in8/2)+in9;
                          int int1 = sprite.Height;
                          int int2 = sprite.Width;
                          int help1 = (int1/distance)*100;
                          int help2 = (int2/distance)*100;
                          debug.Text = String.Format("%d, help1=%d, help2=%d, size = %d", distance, help1, help2, size);
                         if (help1 != 0 && help2 != 0) {
                            sprite.Resize(help1, help2);
                    DrawingSurface *surface1 = Room.GetDrawingSurfaceForBackground();
                              surface1.DrawImage(in5-in7, in6-in71, sprite.Graphic);
                    surface1.Release();
                              sprite.Delete();
                           }
                        }
Title: Re: error: out of memmory: failed to alicate 1600000000 (at PP=6)
Post by: Gilbert on Mon 29/12/2008 08:12:40
I'm not sure how often you call this part of code and I don't have the time to study it carefully, but my guess is, it may be possible that some how the dynamitesprite memory aren't released.
So, try to make sure the sprite got deleted eventually whenever it's not null in the first place , like moving that delete() action one level outwards:

DynamicSprite* sprite = DynamicSprite.CreateFromExistingSprite(in8+in9);
if (sprite != null) {
  int slot = (in8/2)+in9;
  int int1 = sprite.Height;
  int int2 = sprite.Width;
  int help1 = (int1/distance)*100;
  int help2 = (int2/distance)*100;
  debug.Text = String.Format("%d, help1=%d, help2=%d, size = %d", distance, help1, help2, size);
  if (help1 != 0 && help2 != 0) {
    sprite.Resize(help1, help2);
    DrawingSurface *surface1 = Room.GetDrawingSurfaceForBackground();
    surface1.DrawImage(in5-in7, in6-in71, sprite.Graphic);
    surface1.Release();
  }
  sprite.Delete();
}


As dynamitesprites memory should be released automatically this may not be the real reason, but that's worth a try.

Another possibility is that in8+in9 somehow points to an invalid sprite slot. Though after creating the dynamitesprite from an existing slot you check whether the pointer is null, it is not documented (http://www.adventuregamestudio.co.uk/manual/DynamicSprite.CreateFromExistingSprite.htm) that this function will return null in case the slot is not valid (unless it's written elsewhere), so it may be possible that if in8+in9 points to an invalid slot, the function returns garbaged information that cause this problem. I think you may add a Display() line before that function to check whether the calculated slot will be invalid.

Finally, you may also try moving the declaration of the pointers (sprite and surface1) outside of any functions to make them static. I remembered in some old versions of AGS there're some problems with non-static pointers (but could have been fixed).
Title: Re: error: out of memmory: failed to alicate 1600000000 (at PP=6)
Post by: matt on Mon 29/12/2008 08:40:52
 ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D
thanks so much. looking at it in a different view is see that in the transition between ags 2.72 and 3.1.1 that i didn't chang the delete command to realese!!!!!
;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D
Title: Re: error: out of memmory: failed to alicate 1600000000 (at PP=6)
Post by: Pumaman on Mon 29/12/2008 22:37:12
The most likely cause is that the "help1" and "help2" sizes that you're calculating are huge. Try putting this:

Display(debug.Text);

just before the Resize call, to check what the new size is.
Title: Re: error: out of memmory: failed to alicate 1600000000 (at PP=6)
Post by: matt on Tue 30/12/2008 01:30:57
who thanks so much it wanted to resize it to 5000, 5000 pixles!
tnks so much