View Single Post
Old 07 December 2020, 06:25   #6
Warty
Registered User
 
Join Date: Aug 2018
Location: Minneapolis, USA
Posts: 301
I finally worked up a minimal testbed for this, because it was bugging me, but I don't know what the results mean.

Test program: all it does is open a window (on a custom screen, or not). you close the window, the program exits

First of all, the test results:

If I DO open a custom screen, I get these memory leaks:
Code:
The following memory blocks were NOT freed:
 Addr: $54280  Size: 248  RtnAddr: $F8EA6E  Hunk: ROM Space  Ofst: None
 Addr: $42ED40  Size: 10  RtnAddr: $F8EA44  Hunk: ROM Space  Ofst: None
 Addr: $54110  Size: 248  RtnAddr: $F8E9AC  Hunk: ROM Space  Ofst: None
 Addr: $3F4960  Size: 10  RtnAddr: $F8E986  Hunk: ROM Space  Ofst: None
If I do NOT open a custom screen, I get the following memory leaks reported:
Code:
The following memory blocks were NOT freed:
 Addr: $3A9600  Size: 40  RtnAddr: $FB4C46  Hunk: ROM Space  Ofst: None
 Addr: $3EE830  Size: 40  RtnAddr: $FB4C46  Hunk: ROM Space  Ofst: None
 Addr: $3ECDE0  Size: 40  RtnAddr: $FB4C46  Hunk: ROM Space  Ofst: None
If I do NOT open a custom screen, and remove the WA_SizeGadget, the leak goes down to this::
Code:
The following memory blocks were NOT freed:
 Addr: $42AB60  Size: 40  RtnAddr: $FB4C46  Hunk: ROM Space  Ofst: None
If I do NOT open a custom screen, keep the WA_SizeGadget, but remove the Mouse Move IDCMP tag, the leak is:
Code:
The following memory blocks were NOT freed:
 Addr: $42EB50  Size: 40  RtnAddr: $FB4C46  Hunk: ROM Space  Ofst: None
If I do NOT open a custom screen, and further remove the window open tag for WA_SizeGadget, and the tag for ICDMP mouse move, the memory leaks disappear:
Code:
All allocated memory was freed.
Why is there a memory leak from opening the screen? Why, if I comment out the open screen code, do I get those little leaks around the resize gadget and/or mousemove?

I get same leaks when compiling with Bebbo gcc toolchain, as with VBCC. I don't have a native Amiga C compiler, so haven't tested that.

here's the test program:
Code:
#include <exec/types.h>
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include <intuition/screens.h>
#include <clib/intuition_protos.h>
#include <clib/exec_protos.h>
#include <pragmas/intuition_pragmas.h>

#define MINVERSION  40

#define BOOL     unsigned char
#define ULONG    unsigned long
#define WORD     short
#define UWORD	 unsigned short

struct Library        *IntuitionBase;

/******************/


int main(void)
{
	struct Screen        *screen;
	struct Window        *window;
	struct IntuiMessage  *intuiMsg;
	BOOL                  quit;
	WORD                  i;

    if (IntuitionBase      = OpenLibrary("intuition.library", MINVERSION))
    {
        if (screen = OpenScreenTags(NULL,
			SA_Depth,         4,
			SA_LikeWorkbench, TRUE,
			SA_Title,         "Leak Test",
			TAG_DONE))
        {
			if (window = OpenWindowTags(NULL,
				WA_Height,       200,
				WA_Width,        400,
				WA_CustomScreen, screen,
				WA_IDCMP,        IDCMP_CLOSEWINDOW | IDCMP_MOUSEMOVE,
				WA_SizeGadget,   TRUE,
				WA_DragBar,      TRUE,
				WA_CloseGadget,  TRUE,
				WA_Activate,     TRUE,
				TAG_DONE))
			{
				quit = FALSE;
				while (!quit)
				{
					WaitPort(window->UserPort);
					intuiMsg = (struct IntuiMessage *)GetMsg(window->UserPort);

					switch (intuiMsg->Class)
					{
						case IDCMP_CLOSEWINDOW: quit = TRUE;
												break;

					}

					ReplyMsg((struct Message *)intuiMsg);
				}

				CloseWindow(window);
			}

            CloseScreen(screen);
        }

        CloseLibrary(IntuitionBase);
    }

    return 0;
}
Warty is offline  
 
Page generated in 0.04539 seconds with 11 queries