Description
@frankmcsherry came in today asking about help diagnosing a memory leak in timely-dataflow. His program was sitting on 7GB (as observed through the system monitor) with no apparent reason. Eventually we guessed that maybe the allocator was being greedy behind the scenes, and that does appear to be the case, as shown by the following program:
fn main() {
{
let mut test = Vec::new();
for i in 0..1000000000 {
test.push(i);
}
}
loop { }
}
I compiled and ran this program on my Linux machine and observed with top. After escaping the inner scope and reaching the loop, memory continued to hover around 800 MB. This behavior was independent of whether the program was compiled in -O0 or -O3 (though the latter did once fault with an illegal instruction, though this may have just been OOM-killer nondeterminism).
Is there any doubt that this behavior is due to jemalloc? If not, then we should look into providing some way of on-demand requesting that jemalloc dump whatever memory it's gobbled up.