PixarAnimationStudios / OpenUSD

Universal Scene Description

Home Page:http://www.openusd.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Valgrind reports many memory errors in OpenUSD

pgrossomoreira opened this issue · comments

Valgrind started reporting memory errors in OpenUSD after we started using OpenUSD in our project. We've used the following program to reproduce the issue:

#include <pxr/usd/usd/stage.h>

int main(int argc, const char* argv[])
{
    auto s = pxr::UsdStage::CreateInMemory();
    return 0;
}

And here's how we get the memory errors report:
valgrind --xml=yes --xml-file=leaks_report --leak-check=full --show-leak-kinds=all --track-origins=yes --num-callers=50 --demangle=yes ./build/test/test

Even if we don't invoke any USD functions, OpenUSD's initialization alone leaks memory (see #2768).

We've been trying to configure valgrind to supress OpenUSD's memory leaks, but this approach has severe limitations:

  1. It's very time consuming because there are 12K memory errors, even without invoking USD functions. I expect even more errors once we start actually using OpenUSD's functionality
  2. With new releases of OpenUSD, the list of suppressed errors will need to be continuously updated as some errors will stop occurring and new errors will appear. This would be a daunting task.
  3. Even if we do all that work, we can't be sure that we're not supressing legitimate memory leaks, causing valgrind to report false negatives

This can't be the right approach. Surely OpenUSD developers have some way of checking their own code for memory errors without having to read through hundreds of errors every time? How do they do it?

Filed as internal issue #USD-9655