Skip to content

Unfreed memory usage #11

@cork

Description

@cork

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
		}
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions