Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create new object memory leak during physical simulation #149

Open
posszhang opened this issue Apr 12, 2024 · 1 comment
Open

create new object memory leak during physical simulation #149

posszhang opened this issue Apr 12, 2024 · 1 comment

Comments

@posszhang
Copy link

Performs normally in Windows, but leaks in Linux
The above is Golang code, but the performance of pure C++testing is also the same

func testmem() {

	scene, _ := gophysx.NewScene("")
	fmt.Println("newscene")

	for j := 0; j < 400; j++ {
                // simulate  fetchResult
		scene.Update(1.0 / 40.0)

		scene.CreateBoxStatic(gophysx.Vector3{1, 2, 3}, gophysx.Vector3{1, 1, 1})
		scene.CreateBoxStatic(gophysx.Vector3{1, 2, 3}, gophysx.Vector3{1, 1, 1})
		scene.CreateBoxStatic(gophysx.Vector3{1, 2, 3}, gophysx.Vector3{1, 1, 1})
		scene.CreateBoxStatic(gophysx.Vector3{1, 2, 3}, gophysx.Vector3{1, 1, 1})
		scene.CreateBoxStatic(gophysx.Vector3{1, 2, 3}, gophysx.Vector3{1, 1, 1})
	}

	scene.Release()
	fmt.Println("releasescene")
}

func main() {

	for i := 0; i != 10; i++ {

		go func() {
			for j := 0; j != 1000; j++ {
				testmem()
			}
		}()
	}

	for {
		runtime.GC()
		debug.FreeOSMemory()
		time.Sleep(1 * time.Second)
	}

}
@posszhang
Copy link
Author

posszhang commented Apr 17, 2024

linux glibc need malloc_trim
but cgo have leak memory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant