unit testing memory leaks?

11 views
Skip to first unread message

Bob Carpenter

unread,
Dec 29, 2013, 9:27:50 PM12/29/13
to stan...@googlegroups.com
Is there any way to unit test a memory leak?

I have a test for softmax, that if I let it run for
a minute or two clearly shows the leak in 2.1.0
in the process monitor as growing memory usage for
the test.

I also have a hotfix for 2.1.1 that plugs the leak (just
a matter of switching operator new to a direct use of
memalloc_). It doesn't show the memory growth in the
process monitor.

But I don't know how to automate the test. Clearly if
I let it run 15 minutes it'd blow out memory, but that
seems a sub-optimal strategy.

- Bob

Ben Goodrich

unread,
Dec 29, 2013, 11:42:06 PM12/29/13
to stan...@googlegroups.com
On Sunday, December 29, 2013 9:27:50 PM UTC-5, Bob Carpenter wrote:
Is there any way to unit test a memory leak?

On !Windows, you can set the maximum amount of memory a process is allowed to have via

ulimit -v

which will fail quickly in the case of a memory leak. But I don't know how to do the equivalent thing on Windows.

Ben

Daniel Lee

unread,
Dec 30, 2013, 12:15:56 AM12/30/13
to stan...@googlegroups.com

Should we be checking the size of our auto diff stack? Maybe we should be unit testing the underlying vari and explicitly checking that the allocation is done correctly.

I'm not sure exactly what that entails.

--
You received this message because you are subscribed to the Google Groups "stan development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages