Thứ Tư, 24 tháng 4, 2013

Wednesday Memories

Crashes and Memory

Both words are at the forefront of my thoughts this day. I drop in lots of segments, it gobbles up all the memory, then crashes. Wonderful.  My task today has been to first track exactly how much memory is being used on segments (and by extension entities) and then relay that to an on-screen resource bar so I can see the resources grow the larger the level gets.

First Person Game Creator

I did an educational version of FPSC called FPGC which used some extra features such as an entity resource bar so I already have code for this, I have added segments to it now so it's comprehensive.


Notice the green bar at the bottom of the screen. It is nice and out of the way, and will grow as you add things to your level. It will turn red when you are over 900MB of memory used. I plan to cap all levels at 1GB of content, to then allow 800MB for the real time light mapping process and other operations of the application. This should keep me within the virtual address cap and prevent catastrophic crashes.  The above bar tracks both segment and entity usage so it's pretty good measure of what your level consists of.

Next Step

Now this is coded, my next step is to add some code to stop allowing the user to add more entities and segments if the maximum resource is reached. I think this is better than a random crash and allows the user to backtrack and remove some items to finish their level. I would have liked to provide an infinite amount of space for your creations, but for this product we'll have to live with placing content across multiple levels.  There is a technique of loading in content as you get near it, but that's a whole new engine and another product!  Maybe next year :)

Signing Off

The day started late so I will be coming back after dinner to do a little more on this and try to get it to the point where the software cannot be crashed, no matter what I add and what I do. No sense moving on before this is cracked 100% which is the sign of a professional coder (that is, not get excited about a new feature go off to code it, but to stay with what you've done and make sure it's bullet proof). I'm not saying that's me, but I try!

Không có nhận xét nào:

Đăng nhận xét