Excessive system memory use with opengl program

Hi,

I’ve got a program i’m working on that uses texture atlases, and a fair number of VBOs (tens+, to a couple hundred?), max size of each vbo is 25MB in one mode (single vbo per chunk), and 5MB in another (16 slices per chunk). In both, I experience the same issue. The system memory use jumps to 1.5GB, when it should be about 300MB. When I test with the intel and nouveau drivers, I get the expected 300MB use. When I test with the nvidia linux drivers, the memory use is at around 1.5GB on startup. Basically with the binary nvidia drivers, the memory use is SIGNIFICANTLY higher than with mesa/intel/nouveau.

If you’re interested in the code, it’s at mctools/mapviewer at master · Tomasu/mctools · GitHub and has a few dependencies (Allegro 5.1, Physfs, zlib, and three of my libs in my github: libnbt, libmcmap, libioaccess), so it’s not the simplest thing to build.

I’ve since done a fair amount of debugging, as much as i can without source to nvidia’s GL implementation. According to valgrind, there are no memory leaks in my code. And the amount of memory I am directly allocating is somewhere about 300MB. The rest just pops out of nowhere when running with the nvidia driver. This isn’t just “pretend” or virtual memory, as it causes another machine with an nvidia card to freak out, and once needed to be rebooted after running.

Xorg claims my driver is 346.47. I installed the latest one I could find. I have a Quadro K2000M.

Also, this doesn’t seem to happen under windows. It seems to be specific to Linux and the NVidia binary drivers.

Looked at memory use with massif now. It shows 1.2G allocated in libGL.

A statically linked x86-64 version for the current version of Ubuntu would be nice.

I’m not sure NVIDIA would want to spend their time building your app.

I’ll work on getting a static version, but in the mean time, I’ll provide a basic apitrace file, which might help?

It’s not a trace of the full map load, that results in a much much bigger file, but i figure a partial load is good enough as its the same code being called repeatedly. [url]http://tomasu.net/~moose/viewer.trace.gz[/url]

There’s also this massif graph: External Media

Got a new report from my partner on this project, and he says that on windows, he sees just as much system use, about 1.3GB increase, although the program itself uses 100MB or so. But it’s marked the 1.2GB as “cached”. I suspect it’s the same data, but handled in a different way by the driver? Both the linux and windows attempts are with OpenGL.

And here is a static build, built on an x86_64 Debian sid. Not sure if it’ll work on ubuntu?

contains a run.sh script to run it using the included test map and data.

ldd list:

linux-vdso.so.1 (0x00007fff7132b000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fadd3749000)
libSM.so.6 => /usr/lib/x86_64-linux-gnu/libSM.so.6 (0x00007fadd3541000)
libICE.so.6 => /usr/lib/x86_64-linux-gnu/libICE.so.6 (0x00007fadd3323000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007fadd2fe0000)
libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007fadd2dce000)
libXcursor.so.1 => /usr/lib/x86_64-linux-gnu/libXcursor.so.1 (0x00007fadd2bc2000)
libXi.so.6 => /usr/lib/x86_64-linux-gnu/libXi.so.6 (0x00007fadd29b2000)
libXinerama.so.1 => /usr/lib/x86_64-linux-gnu/libXinerama.so.1 (0x00007fadd27af000)
libXrandr.so.2 => /usr/lib/x86_64-linux-gnu/libXrandr.so.2 (0x00007fadd25a4000)
libGLU.so.1 => /usr/lib/x86_64-linux-gnu/libGLU.so.1 (0x00007fadd2336000)
libGL.so.1 => /usr/lib/x86_64-linux-gnu/libGL.so.1 (0x00007fadd1fde000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fadd1dc2000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fadd1ab7000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fadd17b6000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fadd159f000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fadd11f6000)
/lib64/ld-linux-x86-64.so.2 (0x00007fadd399c000)
libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007fadd0ff1000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007fadd0dce000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fadd0bca000)
libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007fadd09c0000)
libXfixes.so.3 => /usr/lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007fadd07b9000)
libnvidia-tls.so.346.47 => /usr/lib/x86_64-linux-gnu/tls/libnvidia-tls.so.346.47 (0x00007fadd05b6000)
libnvidia-glcore.so.346.47 => /usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.346.47 (0x00007fadcd8dc000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007fadcd6d8000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007fadcd4d2000)