Closed Spargwy closed 1 month ago
@mymmrac hi, we have this problem too, help us please
@mymmrac hey, do you have any information about this problem?
@NikBuka I spend some time investigating this, but from my side, don't see any particular issues, there is io.Copy
that allocates some memory, but then it's written to a buffer and writer is closed, so I don't see places where memory leaks, I couldn't reproduce it fully, can you please provide full code example + files you are using + memory profile to see what exactly is happening for you?
@mymmrac Hi. Code example that I provided is fully working. I use pic with size about 18kB(attachment). Just run the bot and start chatting. Really, the problem does not recur?
@Spargwy there are couple of issues with your code:
ByteNamedReader
is incorrect implementation of the reader, it may not return EOF
if read buffer is smaller then file size which is requiredRead
method always returned some data and no error (no EOF
) and it kept reading infinite dataSimply create new InputFile
for each message using tu.NameReader
and bytes.NewReader
:
for update := range updates {
media := []telego.InputMedia{&telego.InputMediaPhoto{
Type: telego.MediaTypePhoto,
Media: telego.InputFile{File: tu.NameReader(bytes.NewReader(fc), "proxy-image.jpg")},
}}
_, err = bot.SendMediaGroup(&telego.SendMediaGroupParams{ChatID: update.Message.Chat.ChatID(), Media: media})
if err != nil {
panic(err)
}
}
💬 Telego version
v0.31.0
👾 Issue description
Calling SendMediaGroup with image but deeper I have a strange growth of bytes buffer
⚡️ Expected behavior
just send media
🧐 Code example