Thanks a lot. Got much to consider now. I’ll definitely monitor memory consumption on my own machine. It might give me some clues. And I’m sorry I didn’t provide enough information. Just to clarify:
I’ve personally tested this on GTX 960, GTX 1050 and Intel(R) UHD Graphics 630. This with debug output on and there are no warnings/errors. I’ve monitored GPU memory usage with gpu-z and memory usage is consistent on those cards.
Additionally, roughly 20 random gamers have tested it as well, without problems, except for two, coincidently on 1080. One of them have provided me with a log:
java.lang.RuntimeException: GLerr: out of memory
at snake2d.GlHelper.checkErrors(GlHelper.java:74)
|-------------------|
| ERROR LOG |
|-------------------|
java.lang.RuntimeException: GLerr: out of memory
at snake2d.GlHelper.checkErrors(GlHelper.java:74)
at snake2d.TextureHolder.<init>(TextureHolder.java:66)
at resources.sprite.composer.Initer$1.getTexture(Initer.java:69)
at resources.sprite.SPRITES.<init>(SPRITES.java:69)
at resources.RES$Data.<init>(RES.java:34)
at resources.RES$Data.<init>(RES.java:32)
at resources.RES$1.doJob(RES.java:62)
at snake2d.CORE.start(CORE.java:183)
at menu.Menu.start(Menu.java:52)
at main.Syx.main(Syx.java:24)
|-------------------|
| STD OUT |
|-------------------|
Game version : Embryo 1.0
Input Arguments :
Starting the Launcher....
SYSTEM INFO
---Running on a: Windows 10, x86 Platform.
---jre: 1.8.0_201
---Processors avalible: 8
---Reserved memory: 1037Mb
---JRE Input Arguments : -Xms512m, -Xmx1024m,
Firing up an engine, v: 0.9
DISPLAY
---current resolution: 1920x1080x60
---supported resolutions:
-----640x480x50,
-----640x480x59,
-----640x480x60,
-----640x480x75,
-----720x480x50,
-----720x480x59,
-----720x480x60,
-----720x480x75,
-----720x576x50,
-----720x576x59,
-----720x576x60,
-----720x576x75,
-----800x600x25,
-----800x600x29,
-----800x600x30,
-----800x600x50,
-----800x600x59,
-----800x600x60,
-----800x600x75,
-----1176x664x50,
-----1176x664x59,
-----1176x664x60,
-----1024x768x25,
-----1024x768x29,
-----1024x768x30,
-----1024x768x50,
-----1024x768x59,
-----1024x768x60,
-----1024x768x75,
-----1280x720x25,
-----1280x720x29,
-----1280x720x30,
-----1280x720x50,
-----1280x720x59,
-----1280x720x60,
-----1280x720x75,
-----1280x768x25,
-----1280x768x29,
-----1280x768x30,
-----1280x768x50,
-----1280x768x59,
-----1280x768x60,
-----1280x768x75,
-----1152x864x25,
-----1152x864x29,
-----1152x864x30,
-----1152x864x50,
-----1152x864x59,
-----1152x864x60,
-----1152x864x75,
-----1280x800x25,
-----1280x800x29,
-----1280x800x30,
-----1280x800x50,
-----1280x800x59,
-----1280x800x60,
-----1280x800x75,
-----1360x768x25,
-----1360x768x29,
-----1360x768x30,
-----1360x768x50,
-----1360x768x59,
-----1360x768x60,
-----1360x768x75,
-----1366x768x25,
-----1366x768x29,
-----1366x768x30,
-----1366x768x50,
-----1366x768x59,
-----1366x768x60,
-----1366x768x75,
-----1280x960x25,
-----1280x960x29,
-----1280x960x30,
-----1280x960x50,
-----1280x960x59,
-----1280x960x60,
-----1280x960x75,
-----1440x900x25,
-----1440x900x29,
-----1440x900x30,
-----1440x900x50,
-----1440x900x59,
-----1440x900x60,
-----1440x900x75,
-----1280x1024x25,
-----1280x1024x29,
-----1280x1024x30,
-----1280x1024x50,
-----1280x1024x59,
-----1280x1024x60,
-----1280x1024x75,
-----1600x900x25,
-----1600x900x29,
-----1600x900x30,
-----1600x900x50,
-----1600x900x59,
-----1600x900x60,
-----1600x900x75,
-----1600x1024x25,
-----1600x1024x29,
-----1600x1024x30,
-----1600x1024x50,
-----1600x1024x59,
-----1600x1024x60,
-----1600x1024x75,
-----1768x992x25,
-----1768x992x29,
-----1768x992x30,
-----1680x1050x25,
-----1680x1050x29,
-----1680x1050x30,
-----1680x1050x50,
-----1680x1050x59,
-----1680x1050x60,
-----1680x1050x75,
-----1600x1200x60,
-----1920x1080x25,
-----1920x1080x29,
-----1920x1080x30,
-----1920x1080x50,
-----1920x1080x59,
-----1920x1080x60,
-----1920x1080x75,
---blit size: 960 480
---created resolution: 1920x1080, 60Hz, vsync: 1
---LWJGL: 3.1.2 build 29
---GLFW: 3.3.0 Win32 WGL EGL VisualC DLL
OPEN_GL
---FB stencil Bits: 0
---FB depth Bits: 0
---FB Red Bits: 8
---FB Green Bits: 8
---FB Blue Bits: 8
---FB Alpha Bits: 8
---Version: 3.3.0 NVIDIA 419.67
---SL Version: 3.30 NVIDIA via Cg compiler
---glRenderer: NVIDIA Corporation, GeForce GTX 1080 Ti/PCIe/SSE2
---Forward compatible: true
SOUND
---AL version : 1.1 ALSOFT 1.17.2
---AL vendor : OpenAL Community
---AL renderer : OpenAL Soft
---OpenALC10: true
---OpenALC11: true
---ALC_FREQUENCY: 48000Hz
---ALC_REFRESH: 50Hz
---ALC_SYNC: false
---Created Mono Sources : 10
---Created Stereo Sources : 6
[LWJGL] OpenGL debug message
ID: 0x20092
Source: API
Type: PERFORMANCE
Severity: MEDIUM
Message: Program/shader state performance warning: Vertex shader in program 1 is being recompiled based on GL state.
[LWJGL] OpenGL debug message
ID: 0x0
Source: API
Type: ERROR
Severity: HIGH
Message: Unknown internal debug message. The NVIDIA OpenGL driver has encountered
an out of memory error. This application might
behave inconsistently and fail.
(pid=25544 javaw.exe 32bit)
[LWJGL] OpenGL debug message
ID: 0x505
Source: API
Type: ERROR
Severity: HIGH
Message: GL_OUT_OF_MEMORY error generated. Failed to allocate memory for texture.
class snake2d.SoundCore sucessfully destroyed
class snake2d.GraphicContext was sucessfully destroyed
Core was sucessfully disposed
The log tells me that the driver has suffered an out of memory error sometime during execution. ( I don’t poll glGetError() during regular execution. The user has then changed a major state in the game (loaded a certain level, etc.), which in turn releases textures VBO’s and such and creates other ones. During this process there are a lot of glGetErrors() which will crash the game if they return something.
This is where the error is caught, though, like I said, I don’t believe the immediate code surrounding it is the culprit.
texture = new _TextureDiffuse(diffuse, true);
if (normal != null)
normalTexture = new _TextureNormal(normal, true);
else
normalTexture = null;
pixelWidth = texture.width;
pixelHeight = texture.height;
texture.bind();
if (normalTexture != null)
normalTexture.bind();
CORE.addTexure(this);
ColorImp.setSPRITE(x1, y1, w, h);
pixels = VboParticles.getForTexture(pixelWidth, pixelHeight);
FBO = glGenFramebuffers();
glBindFramebuffer(GL_FRAMEBUFFER, FBO);
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE, texture.id, 0);
glDrawBuffers(GL_COLOR_ATTACHMENT0);
if (GL_FRAMEBUFFER_COMPLETE != glCheckFramebufferStatus(GL_FRAMEBUFFER))
throw new RuntimeException("Could not create fbo");
glBindFramebuffer(GL_FRAMEBUFFER, 0);
GlHelper.checkErrors();
The last line does glGetError and throws an exception. The user has, however, executed this code once before and that didn’t cause an error.
I hope this sheds some more light. I just find it odd since it works faultlessly on other NVIDIA cards.
I will try out the suggestions you’ve given me so far though. Thanks!
Update:
I can confirm that NVX_gpu_memory_info returns the same values during execution on my GeForce GTX 660M, no memory leak there. Evicted memory is however not 0, but does not change.
This is basically what I do each frame:
glBindVertexArray(vertexArrayID);
glBindBuffer(GL_ARRAY_BUFFER, attributeElementID);
for (int i = 0; i < NR_OF_ATTRIBUTES; i++) {
glEnableVertexAttribArray(i);
}
glBufferSubData(GL_ARRAY_BUFFER, 0, buffer);
shader.bind();
glDrawElements(GL11.GL_POINTS, (to - from), GL11.GL_UNSIGNED_INT, from * 4);
where ‘buffer’ is the vertex data. I’ve initialized the VAO at init:
glBufferData(GL_ARRAY_BUFFER, buffer, GL_STREAM_DRAW);