Suggestions on reducing excessive memory usage

Get help using Construct 2

Post » Mon Dec 15, 2014 5:20 pm

stricky wrote:@Ashley, just to clarify, there are no static frames that are larger than 1024x1024 (max size per frame 200kb), and all frame-by-frame animations are between 2 and 20 frames (max size per frame 50kb). I have looked into Spriter but it can't replicate the look of the complex animations I have hand drawn.

I don't think I'll understand this unless you show some examples of the types of animations you are using. But surely you have must hundreds or even thousands of animation frames in total?

Also when you are stating a size like 50kb, is that just the PNG filesize? As described by Memory usage, the correct calculation to determine the memory usage of a single image is W x H x 4, so a single 1024x1024 frame will use about 4mb of memory alone, regardless of the size of the image file.
Scirra Founder
B
399
S
236
G
89
Posts: 24,519
Reputation: 195,361

Post » Mon Dec 15, 2014 9:12 pm

I assume your game is broken into multiple layouts for different levels?

If so, save a copy of your project somewhere (so you don't accidental go ctrl+s) and experiment with deleting layouts. The memory usage estimate is based on your most intensive layout (whichever one has the largest variety of objects, usually). You may find that a particular level is chewing a lot more memory than your others.

Another question is this: are you targeting desktops exclusively? Because, if so, this may be less of a problem. Most modern desktops/laptops have tons of memory; 2.7GB is a lot, but there are games that use much, much more. As you said, node seems to be dividing the memory across multiple processes, so you are unlikely to hit the 32bit limit.

However, if you were targeting mobile...well, I don't think you are anymore.

The most memory you'll find in a mobile device is 3-4gb, and that's only for the highest end phones and tablets. With the overhead of other apps and OS processes, your game still wouldn't run. It would probably be more trouble than it's worth to strip down your art to the point where you could sandwich it into a mobile's memory.
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Mon Dec 15, 2014 11:55 pm

Sticky for my future reference.
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
23
S
6
G
1
Posts: 1,419
Reputation: 4,857

Post » Tue Dec 16, 2014 10:13 am

@Ashley, those are the image file sizes, the C2 size for the player animation frames would be 262kb per frame (256px * 256 px * 4). There are approximately 1000 player/enemy animation frames in total which works out to 260Mb if I'm not mistaken.

If I add in 300 frames for environment objects per layout, say an average size of 512x512 (some larger, most smaller) that adds up to 300Mb, so rounding up I would expect minimum image memory usage of 600Mb (not including space required for tiled backgrounds which are also used).

The "ImageMemoryUsage" parameter in C2 varies between 600Mb and 1Gb which seems about right, with I assume the other 1.7Gb (of the 2.7Gb total) being taken up by the code/nodewebkit processes. There is a lot of room for improvement in the code, but I'd be surprised if I could claw back another 1Gb. I can't run the game in a browser any more (too big I assume) so I'm not able to use the layout debugger to troubleshoot.

I don't think there's much I can do to reduce image memory usage unless I reduce sprite sizes and/or reduce the number of frames.

Example frames for the player and environment in links below. Edit; Don't have the rep to post links yet.

@TiAm, the game is PC only, so I'm aiming for around 2Gb total memory usage, I estimate half of this will be taken up by image memory, but given I have yet to add audio, I will probably struggle to stay within 2Gb.
B
12
S
2
G
1
Posts: 25
Reputation: 890

Post » Tue Dec 16, 2014 10:38 am

you know that deduplication happens when exporting and images are added on sheets? still i don't know if sheets are being read from / cut from on usage? how much % do they save ?
Sea Monsters template - Isometric
Also includes 40 pages PDF of optimizations and "how-to" for your games, and how the "sea monsters" template was built. Follow link for details :)

sea-monsters-templates-and-assets_t162705
B
43
S
14
G
12
Posts: 626
Reputation: 9,450

Post » Tue Dec 16, 2014 10:29 pm

@stricky

Page thru the manual; you'll get a couple more badges, should push your rep up to where you can post url's.

Anyway, I really don't have any projects I can reference that have the massive number of images yours does; my current project uses 10mb image memory, so it's not that great a comparison.

However, looking at the memory usage of node for a couple sample exports, I did notice something interesting: the 64bit build seems to consume twice as much memory as the 32bit build, at least for my game (~900 events).

It's worth mentioning that I'm using an older 32bit build of node that I find to be more stable, as per this thread:

update-guide-fix-jank-in-r190-node-webkit-export_t119896?&hilit=node+guide

Also, you say you can't preview your game anymore to debug...that seems pretty bad, frankly. Are you using an SSD or a traditional hard drive?

As long as your game is targeting PC, I really think you'll be okay. Even a cheap, low end notebook has at least 4GB of memory in it.
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Previous

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 46 guests