Skip to content
This repository has been archived by the owner on Nov 13, 2021. It is now read-only.

optimize: high memory footprints #301

Open
echoiron opened this issue Sep 10, 2019 · 14 comments
Open

optimize: high memory footprints #301

echoiron opened this issue Sep 10, 2019 · 14 comments

Comments

@echoiron
Copy link

improve : high memory footprints

Hello, our service uses your gopdf framework and has a high memory footprint. feedback

20190910171106

20190910171519

@echoiron echoiron changed the title the memory footprints so high optimize: high memory footprints Sep 10, 2019
@jung-kurt
Copy link
Owner

This may be related to #110. Do you include high-resolution images in your documents?

@echoiron
Copy link
Author

thanks reply.
document is in plain text.

@echoiron
Copy link
Author

echoiron commented Sep 11, 2019

memory not released

20190911092815

@jung-kurt
Copy link
Owner

Is your application a long-running service? If so, does the memory usage continue to get larger or does it plateau at some level?

@echoiron
Copy link
Author

yes,our server is a long-running and memory usage will continue to grow

@echoiron
Copy link
Author

pdf api code

@echoiron
Copy link
Author

pprof monitor

@echoiron
Copy link
Author

pprof traces

Type: inuse_space
Time: Sep 16, 2019 at 9:52am (CST)
-----------+-------------------------------------------------------
     bytes:  72kB
         0   bytes.makeSlice
             bytes.(*Buffer).grow
             bytes.(*Buffer).Write
             encoding/json.intEncoder
             encoding/json.arrayEncoder.encode
             encoding/json.sliceEncoder.encode
             encoding/json.structEncoder.encode
             encoding/json.ptrEncoder.encode
             encoding/json.(*encodeState).reflectValue
             encoding/json.(*encodeState).marshal
             encoding/json.Marshal
             github.com/jung-kurt/gofpdf.generateFontID
             github.com/jung-kurt/gofpdf.(*Fpdf).addFont
             github.com/jung-kurt/gofpdf.(*Fpdf).AddUTF8Font
             beegopdf/controllers.(*PdfGeneratorController).HandlerPdfGenerator
             reflect.Value.call
             reflect.Value.Call
             github.com/astaxie/beego.(*ControllerRegister).ServeHTTP
             net/http.serverHandler.ServeHTTP
             net/http.(*conn).serve
-----------+-------------------------------------------------------
...
...
-----------+-------------------------------------------------------
     bytes:  2.26MB
         0   github.com/jung-kurt/gofpdf.(*utf8FontFile).generateSCCSDictionaries
             github.com/jung-kurt/gofpdf.(*utf8FontFile).parseTables
             github.com/jung-kurt/gofpdf.(*utf8FontFile).parseFile
             github.com/jung-kurt/gofpdf.(*Fpdf).addFont
             github.com/jung-kurt/gofpdf.(*Fpdf).AddUTF8Font
             beegopdf/controllers.(*PdfGeneratorController).HandlerPdfGenerator
             reflect.Value.call
             reflect.Value.Call
             github.com/astaxie/beego.(*ControllerRegister).ServeHTTP
             net/http.serverHandler.ServeHTTP
             net/http.(*conn).serve
-----------+-------------------------------------------------------
     bytes:  1.20MB
         0   github.com/jung-kurt/gofpdf.(*utf8FontFile).generateSCCSDictionaries
             github.com/jung-kurt/gofpdf.(*utf8FontFile).parseTables
             github.com/jung-kurt/gofpdf.(*utf8FontFile).parseFile
             github.com/jung-kurt/gofpdf.(*Fpdf).addFont
             github.com/jung-kurt/gofpdf.(*Fpdf).AddUTF8Font
             beegopdf/controllers.(*PdfGeneratorController).HandlerPdfGenerator
             reflect.Value.call
             reflect.Value.Call
             github.com/astaxie/beego.(*ControllerRegister).ServeHTTP
             net/http.serverHandler.ServeHTTP
             net/http.(*conn).serve
-----------+-------------------------------------------------------
...
-----------+-------------------------------------------------------
     bytes:  20.77MB
   20.77MB   bytes.makeSlice
             bytes.(*Buffer).grow
             bytes.(*Buffer).Grow
             io/ioutil.readAll
             io/ioutil.ReadFile
             github.com/jung-kurt/gofpdf.(*Fpdf).addFont
             github.com/jung-kurt/gofpdf.(*Fpdf).AddUTF8Font
             beegopdf/controllers.(*PdfGeneratorController).HandlerPdfGenerator
             reflect.Value.call
             reflect.Value.Call
             github.com/astaxie/beego.(*ControllerRegister).ServeHTTP
             net/http.serverHandler.ServeHTTP
             net/http.(*conn).serve
-----------+-------------------------------------------------------
...
-----------+-------------------------------------------------------
     bytes:  11.16MB
   11.16MB   bytes.makeSlice
             bytes.(*Buffer).grow
             bytes.(*Buffer).Grow
             io/ioutil.readAll
             io/ioutil.ReadFile
             github.com/jung-kurt/gofpdf.(*Fpdf).addFont
             github.com/jung-kurt/gofpdf.(*Fpdf).AddUTF8Font
             beegopdf/controllers.(*PdfGeneratorController).HandlerPdfGenerator
             reflect.Value.call
             reflect.Value.Call
             github.com/astaxie/beego.(*ControllerRegister).ServeHTTP
             net/http.serverHandler.ServeHTTP
             net/http.(*conn).serve
-----------+-------------------------------------------------------
...
-----------+-------------------------------------------------------
     bytes:  9.30MB
    9.30MB   bytes.makeSlice
             bytes.(*Buffer).grow
             bytes.(*Buffer).Grow
             io/ioutil.readAll
             io/ioutil.ReadFile
             github.com/jung-kurt/gofpdf.(*Fpdf).addFont
             github.com/jung-kurt/gofpdf.(*Fpdf).AddUTF8Font
             beegopdf/controllers.(*PdfGeneratorController).HandlerPdfGenerator
             reflect.Value.call
             reflect.Value.Call
             github.com/astaxie/beego.(*ControllerRegister).ServeHTTP
             net/http.serverHandler.ServeHTTP
             net/http.(*conn).serve
-----------+-------------------------------------------------------
...
-----------+-------------------------------------------------------
     bytes:  64B
         0   syscall.UTF16ToString
             internal/syscall/windows/registry.Key.ReadSubKeyNames
             mime.initMimeWindows
             mime.initMime
             sync.(*Once).Do
             mime.AddExtensionType
             github.com/astaxie/beego.registerMime
             github.com/astaxie/beego.initBeforeHTTPRun
             github.com/astaxie/beego.Run
             main.main
             runtime.main
-----------+-------------------------------------------------------

@echoiron
Copy link
Author

hello author ,
could you add close methods of「AddUTF8Font」?
although golang gc automatically reclaims memory, but time is slow.

@jung-kurt
Copy link
Owner

Thank you, @dajiugo, for tracking this problem down.

could you add close methods of「AddUTF8Font」?

Yes, I will do this shortly.

@Antonboom
Copy link

Antonboom commented Sep 19, 2019

+1

I've opened a similar issue to gopdf: signintech/gopdf#116
But later realized that the problem is not in leaks, but in the work of the application process.

@Antonboom
Copy link

Any news? 😢

@jung-kurt
Copy link
Owner

Any news?

Not yet -- hopefully soon.

@Antonboom
Copy link

Antonboom commented Oct 7, 2019

#321

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants