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
Changing RichText
content by invoking RichText.ParseMarkdown
leads to linear growth of memory consumption. In the practical case I faced it took gigabytes of RAM in a couple of hours.
How to reproduce
To reproduce — call RichText.ParseMarkdown
many times with different content. Or just use the snippet I attached below.
Screenshots
Memory growth (one line per second):
Example code
package main
import (
"fmt"
"runtime"
"time"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/widget"
"github.com/google/uuid"
)
func main() {
a := app.New()
w := a.NewWindow("Fyne's RichText Memory Leak")
w.Resize(fyne.NewSize(128, 128/1.618))
rt := widget.NewRichText()
go func() {
var m runtime.MemStats
for {
time.Sleep(time.Second)
// Force GC just to make measurements a bit more precise.
runtime.GC()
// Report memory consumption.
runtime.ReadMemStats(&m)
fmt.Printf(
"Sys: %v MiB\tHeapAlloc: %v MiB\tTotalAlloc: %v MiB\tNumGC: %v\n",
m.Sys/1024/1024, m.HeapAlloc/1024/1024, m.TotalAlloc/1024/1024, m.NumGC,
)
}
}()
go func() {
for {
rt.ParseMarkdown(uuid.NewString())
}
}()
w.SetContent(rt)
w.ShowAndRun()
}
Fyne version
2.4.4
Go compiler version
1.22.1
Operating system and version
macOS Sonoma 14.4
Additional Information
No response
Activity