Closed
Description
Checklist
- I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
- This issue only relates to a single bug. I will open new issues for any other problems.
Describe the bug
- When I use widget.NewMultiLineEntry with Entry.SetText() function as my app log area, there appera a memory leak
- I tried to comment out the SetText function and the memory leak was relieved。
How to reproduce
- Just run the code in this issue, there is no pprof code, and it can reproduce
Screenshots
No response
Example code
- Code with pprof
package main
import (
"fmt"
"net/http"
_ "net/http/pprof"
"strings"
"time"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/widget"
)
var logs = []string{}
var maxLogTake = 50
func main() {
go func() {
http.ListenAndServe("0.0.0.0:10000", nil)
}()
app := app.New()
win := app.NewWindow("Hello World!")
logArea := widget.NewMultiLineEntry()
logArea.SetMinRowsVisible(15)
content := container.NewVBox(
container.NewHBox(
widget.NewLabel("Click the button"),
widget.NewButton("Log Test", func() {
s_now := time.Now().Format("2006-01-02 15:04:05")
for i := 0; i < 50; i++ {
logs = append(logs, fmt.Sprintf("[Log](%v): %v", s_now, i))
}
logLen := len(logs)
if logLen > maxLogTake {
logs = append(logs[0:0], logs[logLen-maxLogTake:]...)
logLen = maxLogTake
}
s_logs := strings.Join(logs, "\r\n")
logArea.SetText(s_logs)
logArea.CursorRow = logLen
logArea.Refresh()
}),
),
logArea,
)
win.Resize(fyne.NewSize(450, 320))
win.SetContent(content)
win.ShowAndRun()
}
Fyne version
2.3.5
Go compiler version
1.20.2
Operating system and version
Windows 10
Additional Information
No response
Activity