This repository contains a demo application that can be used to demonstrate JetBrains dotMemory and dotMemory Unit.
The demo application contains various memory issues, such as memory leaks, high memory traffic and so on. It is used in various screencasts available from our documentation.
The demo application is an implementation of Conway's Game of Life, where we can experiment with structures that evolve through generations.
The solution file contains two projects:
- GameOfLife - The Game of Life implementation, featuring various memory issues.
- Tests - Unit tests that use dotMemory Unit to validate memory behaviour.
The Game of Life can be profiled using dotMemory, with various settings (such as collecting allocations or not).
There are various issues to be uncovered. Some are easy to find using dotMemory's automatic inspections, while others require a bit more investigation.
Discovering memory issues is one thing, making sure the will not occur again is another. The tests project contains various unit tests that make use of dotMemory Unit and replay profiling sessions in code. These tests will fail when run, as the memory leaks are still in the code base. Throughout the code, there are also comments that help resolve the memory issues.
For example, this test verifies the amount of memory allocated during execution:
[Test]
[AssertTraffic(AllocatedSizeInBytes = 2*Mb)] // --assert
public void WholeRunTraffic()
{
// --act
var target = new PetriDish(160, 100, timer);
for (var i = 0; i < 100; i++)
target.PerformOneStep();
}
Searching for WholeRunTraffic
will pinpoint the location of the test failure and provide a hint for fixing it.