Added some code to start spitting out the memory being used pre- and post- a forced garbage collection after 15 seconds, then pause the game when the post-GC memory stops changing.
With the server not running, and me not touching anything, we should get semi-consistent results, right?
if (Time.time > 15f) {
if (totalMemory == 0f) { // first time through
totalMemory = GC.GetTotalMemory(false);
print("Total Memory at time " + Time.time + " pre-GC: " + totalMemory.ToString("N"));
}
totalMemory = GC.GetTotalMemory(true);
if (oldTotalMemory == totalMemory) {
print("Total Memory at time " + Time.time + " post-GC: " + totalMemory.ToString("N"));
Debug.Break();
}
oldTotalMemory = totalMemory;
}
First run:
Total Memory at time 15.00965 pre-GC: 27,811,840.00
Total Memory at time 15.14369 post-GC: 19,075,070.00
Second run:
Total Memory at time 15.00806 pre-GC: 24,526,850.00
Total Memory at time 15.15492 post-GC: 19,468,290.00
Third run:
Total Memory at time 15.01008 pre-GC: 24,870,910.00
Total Memory at time 15.15714 post-GC: 19,496,960.00
Fourth run:
Total Memory at time 15.00175 pre-GC: 24,616,960.00
Total Memory at time 15.13237 post-GC: 19,505,150.00
…so at least we have a baseline as we make changes that will take less/more memory. Commented out for now, wondering if I’ll actually use it before just switching to Unity 5 and using the built-in Profiler.
Cellular cleanup
Like we did with NPCs, let’s cut down on the size of some of the Cells we’re keeping around:
The tricky bit: As the NPC is being generated/reset, hits and hitsFull are set individually, so there’s a time when we would instantiate a damage indicator unnecessarily.
We can avoid that by defaulting hitsFull to 1 and hits to maxint.
publicvoid Reset() {
oldPosition = newPosition = transform.position;
oldScale = newScale = transform.localScale;
timeSinceStable = 0f;
toBeSeen = true;
npcId = 0;
name = "undefined";
lastActiveRound = 0;
hitsFull = 1; hits = int.MaxValue; // So that during initialization our health is always full.
presumedDead = false;
hasMostHated = false;
mostHatedId = 0;
}
Other
Whatcha Playin'?
Currently,
Volume from Mike Bithell and friends. Just playing through the story, and I’m not very good, but I’m completely hooked. Have to set a timer so I
don’t “One more level…” myself into oblivion.
Good news
Since upgrading to Unity 4.6.8, I haven’t had any more lockups of MonoDevelop. Yay!
Sorry
Random Autumn illness and busy times at work have made these “days” way less frequent when they should be. Hope to improve on that.