POV-Ray : Newsgroups : povray.programming : and another one, possible memory leak Server Time
1 Jun 2024 15:40:42 EDT (-0400)
  and another one, possible memory leak (Message 1 to 5 of 5)  
From: Daniel Hulme
Subject: and another one, possible memory leak
Date: 29 Oct 2004 06:30:10
Message: <20041029113009.464970ed@dh286.pem.cam.ac.uk>
In interior.cpp there is a function Copy_Interior. It just copies the
interior struct. Shouldn't it set the reference count on the new struct
to 1, as there is only one pointer to the new struct? Would this
constitute a memory leak if you copy an INTERIOR with more than one
reference and then Destroy_Interior the copy? Does anyone read these
posts or am I talking to myself?

Daniel

-- 
A most peculiar man    With the windows closed      And Mrs Reardon says
He died last Saturday  So he'd never wake up  He has a brother somewhere
He turned on the gas   To his silent world   Who should be notified soon
And he went to sleep   And his tiny room    .oO( http://sad.istic.org/ )


Post a reply to this message

From: Le Forgeron
Subject: Re: and another one, possible memory leak
Date: 29 Oct 2004 08:05:56
Message: <Xns95918F6C16AE0jgrimbertmeandmyself@203.29.75.35>


> In interior.cpp there is a function Copy_Interior. It just copies the
> interior struct. Shouldn't it set the reference count on the new struct
> to 1, as there is only one pointer to the new struct? Would this
> constitute a memory leak if you copy an INTERIOR with more than one
> reference and then Destroy_Interior the copy? Does anyone read these
> posts or am I talking to myself?
> 
> Daniel
> 

I read... but do I care, that's totally another question.
I did not go look at the code, but did you check that:
 - it copy the reference count, really ?
 - didn't it create the interior structure first, with the count set to 1
   during the creation.



-- 




l'habillement, les chaussures que le maquillage et les accessoires.


Post a reply to this message

From: Daniel Hulme
Subject: Re: and another one, possible memory leak
Date: 29 Oct 2004 08:10:50
Message: <20041029131050.0357d30a@dh286.pem.cam.ac.uk>
> I did not go look at the code, but did you check that:
>  - it copy the reference count, really ?
>  - didn't it create the interior structure first, with the count set
>  to 1 during the creation.
Yes, it did both of these:
    New = Create_Interior();

    *New = *Old;

It then goes on to do some deep copying. Now, I may be mistaken, but I
was under the impression that *x = *y did a shallow copy. Since the
reference count is an int and not an int*, that means the reference
count is copied, over the existing count of 1.

Daniel

-- 
A most peculiar man    With the windows closed      And Mrs Reardon says
He died last Saturday  So he'd never wake up  He has a brother somewhere
He turned on the gas   To his silent world   Who should be notified soon
And he went to sleep   And his tiny room    .oO( http://sad.istic.org/ )


Post a reply to this message

From: Mike Raiford
Subject: Re: and another one, possible memory leak
Date: 29 Oct 2004 08:33:26
Message: <41823896$1@news.povray.org>
Daniel Hulme wrote:

> Yes, it did both of these:
>     New = Create_Interior();
> 
>     *New = *Old;
> 
> It then goes on to do some deep copying. Now, I may be mistaken, but I
> was under the impression that *x = *y did a shallow copy. Since the
> reference count is an int and not an int*, that means the reference
> count is copied, over the existing count of 1.

If there is no copy constructor and no operator=, it does a memberwise 
copy. Same as memcpy(New,Old,sizeof(struct)).

-- 
~Mike


Post a reply to this message

From: Daniel Hulme
Subject: Re: and another one, possible memory leak
Date: 29 Oct 2004 09:37:05
Message: <20041029143705.4959935e@dh286.pem.cam.ac.uk>
> If there is no copy constructor and no operator=, it does a memberwise
> copy. Same as memcpy(New,Old,sizeof(struct)).
Exactly. There is no copy constructor nor operator=, so the References
field gets copied along with everything else.

Daniel

-- 
A most peculiar man    With the windows closed      And Mrs Reardon says
He died last Saturday  So he'd never wake up  He has a brother somewhere
He turned on the gas   To his silent world   Who should be notified soon
And he went to sleep   And his tiny room    .oO( http://sad.istic.org/ )


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.