[ISSUE] AGS Creating Multiple Instances of Sprites in Memory

Started by Ryan Timothy B, Wed 08/02/2012 00:47:22

Previous topic - Next topic

Ryan Timothy B

I haven't a clue where to post this considering you're all hoping to have new forum in the future. But I'll point this issue out in case it hasn't been noticed before.

I was doing some tests because of this thread when I discovered this multiple sprites in memory issue.

I create a dynamic sprite that is 6400x4800. The game memory usage becomes: 179,240 KB
I then assign object[0] the above mentioned dynamic sprite. The game memory usage becomes: 419,756 KB
I then assign object[1] the same sprite. The game memory usage becomes: 660,272 KB
Then the same with object[2]. The game memory usage becomes: 900,792 KB
..etc etc..  each time I run this test the memory usage is slightly larger or smaller - which I imagine is expected

There is approximately 240,516 KB difference every time a different object is assigned the same dynamic sprite.
It's significantly worse running the game with Direct3D.

Why would AGS do this? Discuss. Does this need to happen for some hardware reason I'm not familiar with?

Edit: I figured I'd check a sprite that wasn't a dynamic sprite and assigned it to 3 objects. It does the same deal as above.

Gilbert

I've never checked the sources, but maybe the engine has to make a copy of the sprite image whenever an object is to be drawn?

Ryan Timothy B

I sorta understand why it does this, but it should only really need to be doing this if the object is using scaling, tint, flipped, etc.

I imagine that's why it bloats the game each time an object is assigned a sprite because there are two instances of it. The original and the scaled, flipped, tinted, etc version.

Gilbert

Quote from: Ryan Timothy on Wed 08/02/2012 01:51:09
...it should only really need to be doing this if the object is using scaling, tint, flipped, etc.
Maybe this is exactly the reason. What differentiates an unmodified object sprite from a modified one? So, say, an object is zooming in from 10% to 150%. During this process, should the engine not make a copy of the sprite and free the memory specifically at the frame where the scaling is 100%?

SMF spam blocked by CleanTalk