[Done] Canvas Memory Leak ?

Post bugreports for the Mac OSX version here
Wolfram
Enthusiast
Enthusiast
Posts: 567
Joined: Thu May 30, 2013 4:39 pm

[Done] Canvas Memory Leak ?

Post by Wolfram »

If I open and close the second window the used memory, which is shown in Activity Monitor, is growing each time by 1,5MB.
This only happens if the window has a canvas.
Without a canvas, the increase in memory is almost zero.
How can I fix it?

Code: Select all

Global window0, button, window1, canvas

Procedure openCanvas()
  window1 = OpenWindow(#PB_Any, 0, 0, 800, 600, "Sample Editor", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  canvas =CanvasGadget(#PB_Any, 20, 65, 800 -40, 600 -85, #PB_Canvas_ClipMouse | #PB_Canvas_Keyboard)
  
 EndProcedure
 
 
 Procedure MAIN(x = 0, y = 0, width = 450, height = 160)
   window0 = OpenWindow(#PB_Any, x, y, width, height, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   button = ButtonGadget(#PB_Any, 160, 50, 130, 25, "canvas")
   
 EndProcedure
  
  

MAIN()

Repeat
  event = WaitWindowEvent()
  
  If EventWindow() = window0
    Select event
      Case #PB_Event_CloseWindow
        Break
        
      Case #PB_Event_Menu
        Select EventMenu()
          Case #PB_Menu_Quit
            Break
        EndSelect
        
      Case #PB_Event_Gadget
        Select EventGadget()
          Case button
            openCanvas()
        EndSelect
    EndSelect
    
    
  ElseIf EventWindow() = window1
    If event = #PB_Event_CloseWindow
      CloseWindow(window1)
    EndIf
    
  EndIf
  
ForEver
macOS Catalina 10.15.7
User avatar
mk-soft
Always Here
Always Here
Posts: 5249
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Canvas Memory Leak ?

Post by mk-soft »

It is probably a bug that a resource is not released internally.
Please report it as a bug.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
AZJIO
Addict
Addict
Posts: 1257
Joined: Sun May 14, 2017 1:48 am

Re: Canvas Memory Leak ?

Post by AZJIO »

FreeGadget() - improves the situation?

Code: Select all

FreeGadget(canvas)
CloseWindow(window1)
I called it several times and my memory returns to its original size (without FreeGadget).
Wolfram
Enthusiast
Enthusiast
Posts: 567
Joined: Thu May 30, 2013 4:39 pm

Re: Canvas Memory Leak ?

Post by Wolfram »

I already tried freeGadget() and closeWindow() of course.
I'm on macOS Catalina 10.15.7.
macOS Catalina 10.15.7
User avatar
mk-soft
Always Here
Always Here
Posts: 5249
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Canvas Memory Leak ?

Post by mk-soft »

FreeGadget not help and not required. All gadgets are released with CloseWindow
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Wolfram
Enthusiast
Enthusiast
Posts: 567
Joined: Thu May 30, 2013 4:39 pm

Re: Canvas Memory Leak ?

Post by Wolfram »

mk-soft wrote: Sat Dec 09, 2023 10:35 am FreeGadget not help and not required. All gadgets are released with CloseWindow
I know, but I tried to find the problem.
I can reduce the memory leak if put ResizeGadget(canvas, #PB_Ignore, #PB_Ignore, 0, 0) before the closeWindow(window1).

@Fred please can you move this to the Bugs - Mac OSX.
macOS Catalina 10.15.7
User avatar
mk-soft
Always Here
Always Here
Posts: 5249
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Canvas Memory Leak ?

Post by mk-soft »

Without the Debugger!
With ResizeGadget(canvas, #PB_Ignore, #PB_Ignore, 0, 0) before the closeWindow(window1)
crashed sometime the App
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Fred
Administrator
Administrator
Posts: 16522
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Canvas Memory Leak ?

Post by Fred »

Fixed.
Post Reply