Check VRAM usage

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2703
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 51

Check VRAM usage

Post by syedhs »

Hi,

How do you actually 'view' the GPU VRAM usage? Specfically the software suffer from out of memory error during quite a long drive (it is a ground simulator). The software page in and page out okay - judging from the log, and also from the free VRAM report using this code:-

Code: Select all

RenderWindow* win = SimRoot::getSingleton().getRenderWindow();
win->getCustomAttribute("WINDOW", (void*)&mMainWnd);
void *d3dDevice = 0;
win->getCustomAttribute("D3DDEVICE", (void*)&d3dDevice); 
mD3D9 = reinterpret_cast<IDirect3DDevice9*>(d3dDevice );
MYLOG("VRAM left: " + StringConverter::toString(mD3D9->GetAvailableTextureMem()/1000000) +"MB");
All the times, when the out of memory error happened there are stll tremendous amount of VRAM available.

It is possible that there are leakages (like texture not released), but those seem ok using the code snipped above. You can see VRAM going down.. and then as you moved around the VRAM get reduced and increased. Last time when there are bugs causing textures not released, the VRAM get reduced over the time and when it is < 100K, the program starts 'texture-thrashing' ie FPS suddenly gets too low. But now, there are many cases where there are still huge VRAM available, but the Out Of Memory error still thrown.

So to recap:-
1) How do you actually view the available VRAM?
2) Is it possible that VRAM was too fragmented, which then lead to Out Of Memory error?
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
KnightPista
Gnoblar
Posts: 10
Joined: Tue Jun 24, 2014 9:16 am
x 2

Re: Check VRAM usage

Post by KnightPista »

Are you building 32-bit windows app?

We had exactly this problem - crash at no memory, but the available VRAM at the time of crash was enough. The computer was also capable of running application (4 GB VRAM, 16 GB RAM).

The problem turned out to be memory limit for 32-bit application, which is 2 GB. We 'increased' it by using /LARGEADDRESSAWARE as linker option. See: http://msdn.microsoft.com/en-us/library ... 85%29.aspx
Also, the limit 2 GB is in fact less. We got memory crashes at around 1.5 GB (possibly due to fragmentation? i did not investigated further).

To check available memory to the application, we use VMMAP (http://technet.microsoft.com/en-us/sysi ... 35533.aspx).
User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2703
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 51

Re: Check VRAM usage

Post by syedhs »

Wow.. I never thought of that. Yes, the app is 32 bit and I keep focusing on VRAM issues - it is weird that even 4GB VRAM (or we even tested it with Nvidia Titan - 6GB??), it still produced the out of memory error... I will make changes as you recommended. Thanks a bunch! Will update in a few days as testings are needed.
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
User avatar
Zonder
Ogre Magi
Posts: 1168
Joined: Mon Aug 04, 2008 7:51 pm
Location: Manchester - England
x 73

Re: Check VRAM usage

Post by Zonder »

syedhs wrote:Wow.. I never thought of that. Yes, the app is 32 bit and I keep focusing on VRAM issues - it is weird that even 4GB VRAM (or we even tested it with Nvidia Titan - 6GB??), it still produced the out of memory error... I will make changes as you recommended. Thanks a bunch! Will update in a few days as testings are needed.
Windows (in 32bit mode) only has 2Gb of memory available to map for all devices (and only 1gb if you use the /3GB switch, doesn't apply to 64bit os but the 2gb device limit does) so getting around 1.5gb is to be expected. If you have a on board graphics card this can be hogging your ram (limit it in the bios to as low as possible).
There are 10 types of people in the world: Those who understand binary, and those who don't...
Post Reply