NVIDIAGameWorks / PhysX-3.4

NVIDIA PhysX SDK 3.4
https://www.nvidia.com/
2.34k stars 275 forks source link

create new object memory leak during physical simulation #149

Open posszhang opened 3 months ago

posszhang commented 3 months ago

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 commented 3 months ago

linux glibc need malloc_trim but cgo have leak memory