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

Help required: memory leak #4

Open
robbrockbank opened this issue Apr 5, 2023 · 2 comments
Open

Help required: memory leak #4

robbrockbank opened this issue Apr 5, 2023 · 2 comments

Comments

@robbrockbank
Copy link

Hi. I tried this library out to do some transforms and seem to be hitting a large memory leak.

I'm running frequent transforms and memory seems to be increasing each transform in an unbounded way. I've tried reusing the same stylesheet and I've also tried closing it and reloading the stylesheet to perform each transform. In both cases I'm seeing memory climb without limit.

I've run pprof and nothing is showing up in the golang structs - so not leaking anything there. I also did a sanity check switching out this library and exec-ing xsltproc to do the transform instead (everything else remaining the same) and memory footprint remains constant.

Wondering if you had seen this, or had any thoughts as to where the leak may occur. I'm going to keep digging - but if you have any thoughts or pointers as to where/how to investigate then that would be greatly appreciated.

@wamuir
Copy link
Owner

wamuir commented Apr 5, 2023

No memory leaks that I'm aware of. I'm interested in taking a look if you have a shareable example / case where you are experiencing a leak.

@wamuir
Copy link
Owner

wamuir commented Apr 5, 2023

And/or try something similar to this (replacing embed paths) and let me know if you still observe a leak.

package main

import (
	_ "embed"

	"github.com/wamuir/go-xslt"
)

//go:embed path/to/your/stylesheet.xsl
var style []byte

//go:embed path/to/your/document.xml
var doc []byte

func main() {
	for {
		func() {
			xs, err := xslt.NewStylesheet(style)
			if err != nil {
				panic(err)
			}
			defer xs.Close()

			_, err = xs.Transform(doc)
			if err != nil {
				panic(err)
			}
		}()
	}
}

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

2 participants