M
M
MOTORIST2016-07-17 21:24:22
go
MOTORIST, 2016-07-17 21:24:22

Decoder xml eats up memory. What is the problem and how to solve it?

Hello!
There is a function that I use in a loop, it eats up memory:

func decoderXml(f *zip.File) Text {
  d := Text{}
  r, err := f.Open()
  if err != nil {
    fmt.Println(err)
  }
  defer r.Close()

  decoder := xml.NewDecoder(r)
  decoder.CharsetReader = charset.NewReaderLabel
  err = decoder.Decode(&d)

  if err != nil {
    fmt.Printf("Error: %v",err)
  }

  return d
}

PS if you put d = Text{} before return. That's all right.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Semchenko, 2016-07-17
@0xcffaedfe

Ask.
golang-book.ru/chapter-08-pointers.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question