-
Notifications
You must be signed in to change notification settings - Fork 18
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 Leak during continuous image updates #30
Comments
To isolate the problem, the provided code uses randomly generated images instead of actual screen captures. |
Hey @hungry, thanks for the awesome test case! Alas, by outputting Also to improve memory pressure, you might want to add emptyImg := image.NewRGBA(image.Rect(0, 0, width*zoom, height*zoom))
ui.Init()
spot.MountFn(func(ctx *spot.RenderContext) spot.Component {
canvas, SetCanvas := spot.UseState(ctx, emptyImg)
spot.UseEffect(ctx, func() {
... |
Thanks for the quick reply!
|
Might be a weird question, but you did not turn of Go's garbage collection using some environment variable, no? |
Neither intentionally, nor otherwise:
|
I also tried running |
Hey @hungry, I created a PR which should resolve this issue -- tested it on Linux and macOS. Please give it a try and report back: |
This is awesome! Now memory usage is stable, at least for me and this particular test case. Thanks a lot @roblillack ❤️ |
Hello!
I have encountered a memory leak issue when using the Spot library to develop a program that functions similarly to the magnifier tool in Windows. The program continuously captures a portion of the screen, magnifies it, and displays it in a window. However, over time, the memory usage of the program keeps increasing, leading to a memory leak.
Code Snippet
Invocation
go build -ldflags "-s -w" && main.exe
Program output
Expected Behavior
The program should continuously update the displayed image without a significant increase in memory usage.
Actual Behavior
The program's memory usage keeps increasing over time, indicating a memory leak.
Additional Information
Go version: go1.22.5 windows/amd64
Spot library version: v0.3.2
Operating System: Windows 10
I would appreciate any guidance or fixes to resolve this memory leak issue. Thank you!
The text was updated successfully, but these errors were encountered: