/// <summary> /// Takes a Snapshot of the current state and starts to write all Snapshots that are left /// </summary> /// <param name="simData">Current SimulationData to take a Snapshot of</param> public void TakeSnapshot(SimulationData simData, long tick) { int cellCount = simData.Cells.Count(x => x != null); CellSnapshot[] cells = new CellSnapshot[cellCount]; int pos = 0; int i = 0; foreach (PopulationCell cell in simData.Cells) // Not parallel... { if (cell != null) cells[i++] = CellSnapshot.InitializeFromRuntime(cell, pos); ++pos; } TickSnapshot snap = TickSnapshot.IntitializeFromRuntime(tick, cells, simData.Deaths.NotNullIterator().ToArray()); simData.ClearDeaths(); _snapshots.Enqueue(snap); TookSnapshot(this, null); }
public static void TestMemory() { var simData = new SimulationData(DateTime.Now); Console.WriteLine("Current size in MB: " + Process.GetCurrentProcess().PrivateMemorySize64 / (1024 * 1024)); Console.WriteLine("Total Humancount in 1000: " + simData.Cells.Length * 8 / 1000); }