kvark's picture

GameWindow fails to delete device context

Project:The Open Toolkit library
Version:0.9.8-1
Component:Code
Category:bug report
Priority:normal
Assigned:the Fiddler
Status:closed
Description

Creating a GL 3.0 forward-compatible context GameWindow.
After window closing the log reports a warning:

[Warning] Failed to release device context -1442770760. Windows error: 1412.

AttachmentSize
Full application log1.92 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

#1

Thanks.

Judging from the log, this is relatively harmless: a DC reference remains live after the window it refers to is disposed. The error should be easy to fix once I manage to reproduce it.

kvark's picture

#2

This may help you to reproduce it:
WinXP SP3, .NET 3.5
Catalyst 9.5 on Radeon HD 2400
GL 3.0 fw-compat context

the Fiddler's picture

#3

Title:GameWindow fails to delete GL context» GameWindow fails to delete device context
Assigned to:Anonymous» the Fiddler
kvark's picture

#4

Just checkout'ed the source from SVN and built. The warning message changed:

[Warning] INativeWindow leaked (OpenTK.Platform.Windows.WinGLNative). Did you forget to call INativeWindow.Dispose()?
[Warning] OpenGL context 196608 leaked. Did you forget to call IGraphicsContext.Dispose()?

the Fiddler's picture

#5

Status:open» closed

I can reproduce this on 0.9.8-1, but not 0.9.9-0 - seems it is already fixed there. :)

the Fiddler's picture

#7

Status:closed» open

Sorry, I posted while you where typing. Did you checkout trunk or branches/0.9.8?

kvark's picture

#8

Trunk.
I'm glad you are able to reproduce it.

the Fiddler's picture

#9

Just to make sure, are you calling Dispose() on the GameWindow?

Ideally you'd use the disposable pattern, which calls dispose for you:

using (GameWindow game = new GameWindow())
{
    game.Run(60);
}
kvark's picture

#10

Status:open» closed

No, I'm not:)

At the time I started using GameWindow, I didn't know what is 'using' for...
It's a pity the one has to use Dispose/using in order to keep things in proper order for the destruction.

Thank's, Fiddler

the Fiddler's picture

#11

No problem :)

Classes that hold unmanaged resources tend to implement IDisposable, because they don't play well with the GC. The .Net runtime trades convenience (deterministic finalization) for performance and the only way to get this back is to use a hack like IDisposable.