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 leak in bitmap object handling #363

Open
dmcoles opened this issue Oct 12, 2023 · 3 comments
Open

Memory leak in bitmap object handling #363

dmcoles opened this issue Oct 12, 2023 · 3 comments

Comments

@dmcoles
Copy link

dmcoles commented Oct 12, 2023

while developing a tool using MUI 5 I believe I have discovered a memory leak when handling BitmapObject with MUIA_Bitmap_Transparent set to 0.

The following AmigaE code replicates the issue


OPT STACK=35000

  MODULE 'muimaster' , 'libraries/mui'
  MODULE 'tools/boopsi'
  MODULE 'intuition/classusr','exec/memory','graphics/gfx'
  MODULE 'dos/dos'

PROC main()
  DEF bitmapItem
  DEF bitmap:PTR TO bitmap
  DEF planes
  DEF windowGroupRoot
  DEF winMain
  DEF i
  DEF app

  IF ( muimasterbase := OpenLibrary( 'muimaster.library' , MUIMASTER_VMIN ) )
    NEW bitmap
    InitBitMap(bitmap,1,128,30)
    planes:=NewM(16*30,MEMF_CHIP OR MEMF_CLEAR)
    bitmap.planes[0]:=planes


    app := Mui_NewObjectA('Application.mui',[
      MUIA_Application_Window , winMain := Mui_NewObjectA('Window.mui',[
        MUIA_Window_RootObject ,  windowGroupRoot := Mui_NewObjectA('Group.mui',[
          MUIA_Group_Child, bitmapItem:=Mui_NewObjectA('Bitmap.mui',[
            MUIA_Bitmap_Height,30,
            MUIA_Bitmap_Width,128,
            MUIA_Bitmap_Transparent,0,
            MUIA_Bitmap_Bitmap,bitmap,
          0]),
        0]),
      0]),
    0])

    set( winMain ,MUIA_Window_Open , MUI_TRUE )

    FOR i:=0 TO 100
      EXIT CtrlC()
      Delay(50)
      domethod(windowGroupRoot,[MUIM_Group_InitChange])
      domethod(windowGroupRoot,[OM_REMMEMBER,bitmapItem])
      domethod(windowGroupRoot,[OM_ADDMEMBER,bitmapItem])
      domethod(windowGroupRoot,[MUIM_Group_ExitChange])
      Execute('avail flush',0,0)
    ENDFOR
  
    Mui_DisposeObject(app)
    IF bitmap THEN END bitmap
    IF planes THEN Dispose(planes)

  ENDIF
  IF muimasterbase  THEN CloseLibrary( muimasterbase )
ENDPROC

Simply removing and re-adding the bitmap object from the parent group in a loop causes the memory usage to increase each time around the loop.

@dmcoles
Copy link
Author

dmcoles commented Oct 12, 2023

leak

@tboeckel
Copy link
Contributor

Does this happen without MUIA_Bitmap_Transparent=0 as well?

@dmcoles
Copy link
Author

dmcoles commented Oct 15, 2023

No it doesn't happen without that.

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