Created
March 5, 2019 19:10
-
-
Save triplefox/402966607e10e0bcef9d2c384fb28b79 to your computer and use it in GitHub Desktop.
Test case for go-glfw dying due to memory allocation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// allocation_death.go | |
package main | |
import ( | |
_ "image" | |
"github.com/go-gl/gl/v4.1-core/gl" | |
"github.com/go-gl/glfw/v3.2/glfw" | |
) | |
func main() { | |
glfw.Init() | |
window, _ := glfw.CreateWindow(640, 480, "allocation death", nil, nil) | |
window.MakeContextCurrent() | |
gl.Init() | |
var data []byte | |
for !window.ShouldClose() { | |
data = make([]byte, 1000*1000*4) | |
glfw.PollEvents() | |
glfw.SwapInterval(1) // suddenly, the context disappeared? | |
window.SwapBuffers() | |
} | |
data[0] = 1 | |
/* close GL context and any other GLFW resources */ | |
glfw.Terminate() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment