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

gtk.Picture memory leak #144

Open
iamdrq opened this issue Jun 7, 2024 · 1 comment
Open

gtk.Picture memory leak #144

iamdrq opened this issue Jun 7, 2024 · 1 comment

Comments

@iamdrq
Copy link

iamdrq commented Jun 7, 2024

First.Thanks for your work.

This is a test demo:

package main

import (
	"github.com/diamondburned/gotk4/pkg/gdk/v4"
	"github.com/diamondburned/gotk4/pkg/gio/v2"
	"github.com/diamondburned/gotk4/pkg/glib/v2"
	"github.com/diamondburned/gotk4/pkg/gtk/v4"
	"github.com/disintegration/imaging"
	"log"
	"os"
	"runtime"
	"time"
)

func main() {
	application := gtk.NewApplication("com.demo", gio.ApplicationFlagsNone)
	application.Connect("activate", func() {
		log.Println("application activate")
		w := gtk.NewWindow()
		w.SetVisible(true)
		img := gtk.NewPicture()
		img.SetVisible(true)
		w.SetChild(img)
		application.AddWindow(w)
		go func() {
			for range time.Tick(time.Second) {
				src, _ := imaging.Open("a.png")
				dst := imaging.Blur(src, 1)
				glib.IdleAdd(func() {
					data := glib.NewBytes(dst.Pix)
					text := gdk.NewMemoryTexture(dst.Bounds().Dx(), dst.Bounds().Dy(), gdk.MemoryR8G8B8A8, data, uint(dst.Stride))
					img.SetPaintable(text)
					runtime.GC()
				})
			}
		}()
	})
	os.Exit(application.Run(os.Args))
}

Run this that memory always increate.

@jgillich
Copy link
Contributor

Likely the same as #126. Was fixed at some point but that was rolled back due to crashes

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

2 participants