Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
121 user(s) are online (114 user(s) are browsing Forums)

Members: 1
Guests: 120

rjd324, more...

Support us!

Headlines

 
  Register To Post  

Disposing of objects
Just popping in
Just popping in


See User information
Is there a preferred way to check if an object is allocated before disposing? I just don't think all of mine are being disposed of.

[allocate node]
LocalContentNode->DefaultImage=NULL;
--- OR ---
LocalContentNode->DefaultImage=ZERO;


VOID
FreeContentNode
(struct ContentNode *LocalContentNode)
{
    if (
LocalContentNode->DefaultImage != NULL)
    {
        
DisposeImage(LocalContentNode->DefaultImage);
        
LocalContentNode->DefaultImage=NULL;
    }
    if (
LocalContentNode->Text1Label != NULL)
    {
        
IIntuition->DisposeObject(LocalContentNode->Text1Label);
        
LocalContentNode->Text1Label=NULL;
    }
    if (
LocalContentNode->Text2Label != NULL)
    {
        
IIntuition->DisposeObject(LocalContentNode->Text2Label);
        
LocalContentNode->Text2Label=NULL;
    }
}

--- OR ---

VOID
FreeContentNode
(struct ContentNode *LocalContentNode)
{
    if (
LocalContentNode->DefaultImage != ZERO)
    {
        
DisposeImage(LocalContentNode->DefaultImage);
        
LocalContentNode->DefaultImage=ZERO;
    }
    if (
LocalContentNode->Text1Label != ZERO)
    {
        
IIntuition->DisposeObject(LocalContentNode->Text1Label);
        
LocalContentNode->Text1Label=ZERO;
    }
    if (
LocalContentNode->Text2Label != ZERO)
    {
        
IIntuition->DisposeObject(LocalContentNode->Text2Label);
        
LocalContentNode->Text2Label=ZERO;
    }
}


Go to top
Re: Disposing of objects
Home away from home
Home away from home


See User information
NULL is ((APTR)0L)

where as

ZERO id ((BPTR)0L)

So you should use NULL because you dealing with C pointers not BCPL pointers.

ZERO is for locks and file handles.

I would think the code would emits warnings if the wrong one were used...

What makes you think that your objects are being dispoed of?


Go to top
Re: Disposing of objects
Just popping in
Just popping in


See User information
I was using NULL.

I have a memory leak I can't track down. It is much smaller when I don't use images, so....testing all possible options.

Workbench Explorer - A better way to browse drawers
Go to top
Re: Disposing of objects
Home away from home
Home away from home


See User information
@mritter0

How do you determine the memeory leek?

If it by apperent reduction in memeory available in the workbnch title bar, or shown by Avail, then it may not be a leek rather cached data. Bitmap.image caches data for example.

Try running 'expunge all' (should be in the SDK) and see if you get it back.

If your label images have embedded images, then remeber they need to be disposed of sperately unless you specify LABEL_DisposeImage before addibng the image to the label. This is off by default.


Go to top
Re: Disposing of objects
Just popping in
Just popping in


See User information
Good call! Thanks.

I was hoping it was something like that, and not something I was missing.

Is there a way to have it not cache some of the images? Some are very short term and is a "waste" to cache them.

Workbench Explorer - A better way to browse drawers
Go to top
Re: Disposing of objects
Just popping in
Just popping in


See User information
Is there a way to not cache the images? They are very short term and is a waste to cache them.

Img=IIntuition->NewObject(BitMapClass,NULL,
    
BITMAP_SourceFile,                        "PROGDIR:Images/24x1",
    
BITMAP_SelectSourceFile,                "PROGDIR:Images/24x1",
    
BITMAP_DisabledSourceFile,                "PROGDIR:Images/24x1",
    
BITMAP_Screen,                            DefaultPubScreen,
    
BITMAP_Precision,                        PRECISION_EXACT,
    
BITMAP_Masking,                            TRUE,

        
BITMAP_DoNotCache,        TRUE,

TAG_DONE);


Some sort of tag to not cache the image.

Workbench Explorer - A better way to browse drawers
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project