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

Unfreed memory usage #11

Open
cork opened this issue Jan 7, 2020 · 0 comments
Open

Unfreed memory usage #11

cork opened this issue Jan 7, 2020 · 0 comments

Comments

@cork
Copy link

cork commented Jan 7, 2020

I have a problem where i push hundreds of .fodt => .pdf files through this loop and get a ~.5MiB extra memory usage per file and it is not feed (so not gc).
Moving office into the loop explodes the memory usage over time so i'm out of ides. Am i doing something wrong here or is something related to the document not freed on doc.Close()?

type Request struct {
	SourceFile string
	TargetFile string
	TargetExt  string
	Filter     string
	done       chan bool
}

var request chan *Request

func office() {
	office, err := libreofficekit.NewOffice("/usr/lib/libreoffice/program")
	if err != nil {
		log.Fatal(err)
	}
	defer office.Close()

	for {
		select {
		case r := <-request:
			doc, err := office.LoadDocument(r.SourceFile)
			if err != nil {
				office.GetError()
				r.done <- true
				continue
			}
			defer doc.close()

			if err := doc.SaveAs(r.TargetFile, r.TargetExt, r.Filter); err != nil {
				r.done <- true
				continue
			}

			r.done <- true
		}
	}
}
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