Posssible memory leak in OpenGL Intel Win7 drivers

Started by
35 comments, last by mshafey 12 years, 2 months ago

What I described should work using Visual C++ and g++ as well. I don't know about the embedded systems, so thanks for clarifying.


Not for me...
c:\test>cat a.cpp
#include <stdio.h>
int main()
{
int* ptr;
printf("%p\n", ptr);
}
c:\test>g++ a.cpp

c:\test>a.exe
7EFDE000

c:\test>cl a.cpp /nologo
a.cpp
c:\test\a.cpp(5) : warning C4700: uninitialized local variable 'ptr' used

c:\test>a.exe
00000001

c:\test>
Advertisement

[quote name='Yours3!f' timestamp='1329260792' post='4913164']
What I described should work using Visual C++ and g++ as well. I don't know about the embedded systems, so thanks for clarifying.

It works on neither Visual C++ nor g++. Or, rather, it works for the very same reason that your unmapped buffer appeared valid; undefined behavior. Try, for example, to enable optimization and see that happens.
[/quote]

I use kdevelop which uses cmake and by default sets optimization to -O3, I tried in both debug and release mode, both works. Again it shouldn't.
try this:

#include <stdio.h>
int* ptr;
int main()
{
printf("%p\n", ptr);
}[/quote]

try this:

Primitives at global scope are always default initialized to zero. At function scope, they are not.

[quote name='Yours3!f' timestamp='1329262329' post='4913178']
try this:

Primitives at global scope are always default initialized to zero. At function scope, they are not.
[/quote]

I know, that's why replied it. but lets return to the topic now. solving the memory leak...
int *ptr, MSVC 2008, debug build, value of 0x0018f668.

Just because it works on one person's machine using a specific compiler does not make it globally valid. The C/C++ standard is quite explicit that uniitalized pointers are undefined. That means that the compiler is largely free to do whatever it wants with them; it may give a value of 0, it may set to random garbage, and that random garbage may or may not point to somewhere valid in memory.

If you're in the habit of doing this, and of relying on it, please remind me to never use any software you write.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.


If you're in the habit of doing this, and of relying on it, please remind me to never use any software you write.


I always clean up any warning the compiler gives, and this includes uninitialized variables. So that kind of thing isn't going to happen ever in software I write.
But you define all your pointer variables global, not local?

But you define all your pointer variables global, not local?


why did you think that? I just wanted to show you a case where an uninitialized pointer actually is initialized. That was all.
I didn't imply that I use only global variables...
@mshafey

gDEBugger has some nice memory leak tracking features, you should check it out

This topic is closed to new replies.

Advertisement