Skip to content

Instantly share code, notes, and snippets.

@triplefox
Created March 5, 2019 19:10
Show Gist options
  • Save triplefox/402966607e10e0bcef9d2c384fb28b79 to your computer and use it in GitHub Desktop.
Save triplefox/402966607e10e0bcef9d2c384fb28b79 to your computer and use it in GitHub Desktop.
Test case for go-glfw dying due to memory allocation
// 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