UDN
Search public documentation:

MemLeakCheckTracking
日本語訳
中国翻译
한국어

Interested in the Unreal Engine?
Visit the Unreal Technology site.

Looking for jobs and company info?
Check out the Epic games site.

Questions about support via UDN?
Contact the UDN Staff

UE3 Home > Memory System > MemLeakCheck Tracking
UE3 Home > Performance, Profiling, and Optimization > Memory Usage and Profiling > MemLeakCheck Tracking

MemLeakCheck Tracking


Overview


MemLeakCheck provides a really easy to use and understand view of where memory is being used in your game. It is just a text file so you can diff it easily to see changes over time. Simply, MemLeakCheck is a meta command that calls all of the other important memory commands. It's your one-stop shop for memory information.

Running MemLeakCheck


There are two primary ways to run memleakcheck, full and fast:

MemLeakCheck

To generate a full memleakcheck, simply run MemLeakCheck in the console. This will stall your game for a significant amount of time (as much as a minute), but will then output a large file to the Profiling\MemLeaks directory, indexed based on the mapname and timestamp. It may also open it for you in notepad. A full MemLeakCheck contains a list of almost all significant assets, sorted alphabetically. It is broken down into various sections. The full MemLeakCheck is very useful for tracking down Always Loaded Content, and for comparing memory usage over time. The alphabetical sorting should allow simple text diffing in any tool.

MemLeakCheck -fast

If you run MemLeakCheck -fast in the console, it will take a much shorter amount of time (usually around 5 seconds) and print out a less detailed report. This report includes all essential tracking data, but excludes the large asset list as well as any slow operations. It's primarily used for the DoMemLeakChecking command used as part of Hot Spot Report Generation, but is useful if the large stall of the full MemLeakCheck would break functionality (such as network timeouts).

Release vs. Test

One thing to keep in mind is that the output of the MemLeakCheck command differs depending on what executable configuration is used to run it. The Release run has more accurate information, but a Release executable can take significantly more memory than a Test executable so you need to adjust for that. Generally, it's a good idea to use Test with DoMemLeakChecking, and to use Release if you need to take full MemLeakCheck dumps.

Example Usage


There are several different ways you can use the MemLeakCheck command to track down memory issues:

  • If you are leaking memory a quick way to see if it is a UObject memory leak is to do a MemLeakCheck at the start of the map. Run for a while. And then MemLeakCheck again. Diff the two files and look for any differences where it shows a large increase in the number of objects or related pools.
  • During Automated testing you can have a MemLeakCheck be done every 5 minutes. This gives you a nice view of how memory and how objects were changing over the course of the Automated test. Using the MemLeakCheckDiffer tool as described in Hot Spot Report Generation is a quick and easy way to do this.
  • Do a MemLeakCheck to find out where memory is being used in your level. It is really nice to be able to see all of the Dynamically Create objects, seeing how many AnimSets are loaded, etc. Comparing similar situations on two multiplayer maps is a good way to find why a certain map is using more memory than desired.
  • By keeping a repository of old MemLeakCheck data and periodically diffing it to new MemLeakCheck data, you can track the change in memory allocation over the life of a project. This is very useful for tracking down "Why do I suddenly have 5MB less memory than last week?" questions.

Output Sections


The output of a memleakcheck file can be roughly divided into sections. Note, the individual sections of a MemLeakCheck file differ per platform and individual game:

Header

The top of the file has a timestamp, commandline (very useful to check the -reducepoolsize= used for a specific run), BugItGo location, and some memory overview information. When the data in the file doesn't make sense, always make sure to check the header to see if something weird got passed in or if you are looking at an old file. Also, note that for most sections the specific command used to generate that section is listed.

Class List

The Class List is the first major chunk of the file, and is an alphabetically sorted list of every class in the game. Count is self-explanatory. NumBytes is the exact amount of memory that is currently used by all objects of that class. MaxBytes is the amount of allocated memory associated with a class, so includes memory such as TArray slack. ResBytes is the total amount of "Resource" memory associated with objects of that class, and differs in meaning depending on the specific class. TrueResBytes is the amount of "Resource" memory that is needed in addition to any memory used by the object itself. For instance, the TrueResBytes of ParticleSytemComponent is the amount of render-thread memory that is needed for currently active PSCs. Generally, to see how much memory a class is really using you want to add the MaxBytes and the TrueResBytes together.

Specific Object Lists

In a full memleakcheck several detailed lists of objects are present at this point. There are also others farther down. These are similar to the Class List, but list individual assets.

Platform Memory

The next section is platform-specific memory, which varies heavily. In most cases Release mode gives more useful platform memory, and will also output the value of all STAT MEMORY variables.

Game Specific Memory

This section is for any game-specific memory allocations

Rendering memory

Render Targets, GPU Resources, Shader Cache, Texture Streaming, and Octree size are printed out at this point. These are either missing or inaccurate in Test as the data is not available.

Config/Package Memory

The size of all loaded config/localization files, and the full package list are printed out here. The package list is particularly useful for determining what types of data are loaded at a given point, and is present in both full and -fast output.

Asset Lists

In full dumps, it now prints out the complete list of textures, sounds, and particles. There are others farther down, and most of these are skipped in -fast mode.

Actor List

The full actor list, as well as creation times and owners, are printed next. This is extremely useful for finding actor leaks over long play sessions.

Level List

The output of the STAT LEVELS command is printed here. This is great for correlating memory usage to currently loaded levels, which helps when tracking down spikes.