Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leaks in renderers and canvases cache maps #735

Closed
pymq opened this issue Mar 9, 2020 · 1 comment
Closed

Memory leaks in renderers and canvases cache maps #735

pymq opened this issue Mar 9, 2020 · 1 comment

Comments

@pymq
Copy link
Contributor

pymq commented Mar 9, 2020

Describe the bug:

Once created CanvasObject and its renderer are never freed. Two caches are stored here:
internal/driver/glfw/driver.go - canvases
internal/cache/widget.go - renderers
As I can see from code, they are only cleared on window close and only objects that are still in use by that window.
The current workaround is to reuse all widgets but it's hard to do in dynamic interfaces.

To Reproduce:

Continuously create new widgets, for instance in a long running applications.

Example code:

package main

import (
	"time"

	"fyne.io/fyne/app"
	"fyne.io/fyne/widget"
)

func main() {
	a := app.New()
	w := a.NewWindow("test")

	setContent := func() {
		box := widget.NewVBox(
			widget.NewEntry(), widget.NewEntry(),
			widget.NewButton("submit", nil),
		)
		w.SetContent(widget.NewGroup("group", box))
	}

	setContent()
	go func() {
		for range time.NewTicker(100 * time.Millisecond).C {
			setContent()
		}
	}()

	w.CenterOnScreen()
	w.ShowAndRun()
}

Device:

  • Go version: 1.13.8
  • Fyne version: develop, 84bca6e
@fpabl0
Copy link
Member

fpabl0 commented Jul 27, 2021

Fixed on develop.

@fpabl0 fpabl0 closed this as completed Jul 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants