You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
v8go has a leakcheck sanitiser for the c++ code. But we can potentially use profiles to track allocation and release of objects within go, based on build tags.
I've created a PR, with profiles for isolate and context creation and disposal to show how these changes will look: #391. This can be used as shown below:
package main
import (
"fmt"
"os"
"runtime/pprof"
"strings"
v8 "rogchap.com/v8go"
)
func DumpProfiles() {
for _, prof := range pprof.Profiles() {
if strings.HasPrefix(prof.Name(), "rogchap.com") {
_ = prof.WriteTo(os.Stdout, 1)
}
}
}
func Must[T any](t T, err error) T {
if err != nil {
panic(err)
}
return t
}
func main() {
i := v8.NewIsolate()
var vs []*v8.Value
Must(v8.NewValue(i, "derp"))
for j := 0; j < 1000; j++ {
vs = append(vs, Must(v8.NewValue(i, "derp")))
}
fmt.Printf("Profile before Dispose:\n")
DumpProfiles()
for j := 1; j < 1000; j++ {
vs[j].Release()
}
i.Dispose()
fmt.Printf("Profile after Dispose:\n")
DumpProfiles()
}
Which results in something like this, when compiled without tags:
profile-demo$ go run ./cmd/profile-demo
Profile before Dispose:
Profile after Dispose:
And with the tags, we get profiling output, like so:
v8go
has a leakcheck sanitiser for the c++ code. But we can potentially use profiles to track allocation and release of objects within go, based on build tags.I've created a PR, with profiles for
isolate
andcontext
creation and disposal to show how these changes will look: #391. This can be used as shown below:Which results in something like this, when compiled without tags:
And with the tags, we get profiling output, like so:
If there is an appetite for it, for both the maintainers and the community, I will work on the PR further to profile
value.go
as well.The text was updated successfully, but these errors were encountered: