azTrace is a software package designed to help developers understand the memory behavior of their programs. The software has two main components: a set of loggers and a set of analysis tools. The loggers are language-specific (currently there are loggers for Python, Ruby, Java, and PHP) — their purpose is to collect information from running programs in a particular language and write it to a file. Later, the developer can pass these logs to one of several analysis tools. Each tool provides a different visualization or some other sort of summary.
Below are instructions for generating program traces in each supported language.
To profile a program, first run
> ./trackermain.py -m sourcefile.py
Then edit sourcefile.py's main method to include
from trackermain import startup
startup()
Then run the program as normal:
> ./sourcefile.py
To trace a ruby program 'program.rb' and write the log file to 'output.log' from the command line:
> rtrace.rb -o output.log program.rb
Calling the memory tracing facilities from within a Ruby program gives some more control. To perform some basic manual tracing:
require 'tradced'
Traced.trace_classes MyClass, ...
Traced.start_trace 'output.log'
...
Traced.stop_trace
Using the profiler is easy, thanks to the -javaagent flag. Assuming that you are in the directory containing the JAR, simply run your program like this:
java -javaagent:jTrace.jar [program]
If the program you're profiling has a large memory footprint, you may run into an OutOfMemoryError. To avoid this, expand the heap size using the -Xms and -Xmx flags.
The PHP logger is considerably less robust than the others, but it should work with most programs. Most PHP-driven websites have a central entry point, typically index.php, which delegates to other scripts. If this is the case for you, you can attach the profiler just by adding this line to the top of your entry script:
include "phpTrace.php";
Note that the calling script cannot contain function or class definitions. If it does, you'll need to fork them to another script and include that.
The basic usage is as follows:
> ./analyzer.py [options] LOGFILE
There are several separate analysis tools, each invoked with different flags:
-d: output dot file for graphviz processing
-p: output scatterplot
-c: output comma-separated value file
-t: output reference graph statistics
-v: run GUI visualizer
There are other option flags as well, most of them specific to one or more analysis tools. For details, type
> ./analyzer.py -help
Click here to download the latest version of azTrace (1.0).