POV-Ray : Newsgroups : povray.general : memory question Server Time
6 Nov 2024 04:15:55 EST (-0500)
  memory question (Message 1 to 5 of 5)  
From: emkaah
Subject: memory question
Date: 27 Aug 2004 22:21:17
Message: <412fec1d@news.povray.org>
I'm working on a macro, and I get the idea that:

#declare SphereA = sphere{<0,0,0>,5 pigment{Green}}

#declare Count = 0;
union{
  #while (Count<5)
   object{SphereA translate x*2*Count}
   #declare Count = Count + 1;
  #end
}

uses a lot more memory then:

union{
  sphere{<0,0,0>,5 pigment{Green} translate x*2}
  sphere{<0,0,0>,5 pigment{Green} translate x*4}
  sphere{<0,0,0>,5 pigment{Green} translate x*6}
  sphere{<0,0,0>,5 pigment{Green} translate x*8}
  sphere{<0,0,0>,5 pigment{Green} translate x*10}
}

Can somebody tell me this is true? I find this strange for some reason.


Post a reply to this message

From: ZeSly
Subject: Re: memory question
Date: 28 Aug 2004 08:47:44
Message: <41307ef0@news.povray.org>
I found exaltly the same memory usage.

-- 
ZeSly
http://perso.wanadoo.fr/zesly/


news:412fec1d@news.povray.org...
> I'm working on a macro, and I get the idea that:
>
> #declare SphereA = sphere{<0,0,0>,5 pigment{Green}}
>
> #declare Count = 0;
> union{
>   #while (Count<5)
>    object{SphereA translate x*2*Count}
>    #declare Count = Count + 1;
>   #end
> }
>
> uses a lot more memory then:
>
> union{
>   sphere{<0,0,0>,5 pigment{Green} translate x*2}
>   sphere{<0,0,0>,5 pigment{Green} translate x*4}
>   sphere{<0,0,0>,5 pigment{Green} translate x*6}
>   sphere{<0,0,0>,5 pigment{Green} translate x*8}
>   sphere{<0,0,0>,5 pigment{Green} translate x*10}
> }
>
> Can somebody tell me this is true? I find this strange for some reason.
>


Post a reply to this message

From: John VanSickle
Subject: Re: memory question
Date: 28 Aug 2004 12:06:26
Message: <4130ad82$1@news.povray.org>
emkaah wrote:

> I'm working on a macro, and I get the idea that:
> 
> #declare SphereA = sphere{<0,0,0>,5 pigment{Green}}
> 
> #declare Count = 0;
> union{
>  #while (Count<5)
>   object{SphereA translate x*2*Count}
>   #declare Count = Count + 1;
>  #end
> }
> 
> uses a lot more memory then:
> 
> union{
>  sphere{<0,0,0>,5 pigment{Green} translate x*2}
>  sphere{<0,0,0>,5 pigment{Green} translate x*4}
>  sphere{<0,0,0>,5 pigment{Green} translate x*6}
>  sphere{<0,0,0>,5 pigment{Green} translate x*8}
>  sphere{<0,0,0>,5 pigment{Green} translate x*10}
> }
> 
> Can somebody tell me this is true? I find this strange for some reason.

The spheres in the union all use the same texture.  The separately-
declared spheres all use separate textures (since you gave them
separate ones).

So, if you're going to texture a bunch of things the same way, see if
they can go into a union together, and give the union the texture.  This
works very well if the texture is not patterened.

Regards,
John


Post a reply to this message

From: emkaah
Subject: Re: memory question
Date: 28 Aug 2004 15:07:54
Message: <4130d80a@news.povray.org>
Thanks, but that was not the point I am trying to make. But to clear 
things up I refrase the question;

I get the idea that:

#declare SphereA = sphere{<0,0,0>,5}

#declare Count = 0;
union{
  #while (Count<5)
   object{SphereA translate x*2*Count}
   #declare Count = Count + 1;
  #end
  pigment{Green}
}

uses a lot more memory then:

union{
  sphere{<0,0,0>,5 translate x*2}
  sphere{<0,0,0>,5 translate x*4}
  sphere{<0,0,0>,5 translate x*6}
  sphere{<0,0,0>,5 translate x*8}
  sphere{<0,0,0>,5 translate x*10}
  pigment{Green}
}

I solve this problem by writing it to a .inc file with the #write 
function. I just didn't expect a big difference in memory usage with the 
two methods.


John VanSickle wrote:
> emkaah wrote:
> 
>> I'm working on a macro, and I get the idea that:
>>
>> #declare SphereA = sphere{<0,0,0>,5 pigment{Green}}
>>
>> #declare Count = 0;
>> union{
>>  #while (Count<5)
>>   object{SphereA translate x*2*Count}
>>   #declare Count = Count + 1;
>>  #end
>> }
>>
>> uses a lot more memory then:
>>
>> union{
>>  sphere{<0,0,0>,5 pigment{Green} translate x*2}
>>  sphere{<0,0,0>,5 pigment{Green} translate x*4}
>>  sphere{<0,0,0>,5 pigment{Green} translate x*6}
>>  sphere{<0,0,0>,5 pigment{Green} translate x*8}
>>  sphere{<0,0,0>,5 pigment{Green} translate x*10}
>> }
>>
>> Can somebody tell me this is true? I find this strange for some reason.
> 
> 
> The spheres in the union all use the same texture.  The separately-
> declared spheres all use separate textures (since you gave them
> separate ones).
> 
> So, if you're going to texture a bunch of things the same way, see if
> they can go into a union together, and give the union the texture.  This
> works very well if the texture is not patterened.
> 
> Regards,
> John


Post a reply to this message

From: Alain
Subject: Re: memory question
Date: 6 Sep 2004 13:52:35
Message: <413ca3e3$1@news.povray.org>
emkaah nous apporta ses lumieres ainsi en ce 28-08-2004 15:07... :

> Thanks, but that was not the point I am trying to make. But to clear 
> things up I refrase the question;
>
> I get the idea that:
>
> #declare SphereA = sphere{<0,0,0>,5}
>
> #declare Count = 0;
> union{
>  #while (Count<5)
>   object{SphereA translate x*2*Count}
>   #declare Count = Count + 1;
>  #end
>  pigment{Green}
> }
>
> uses a lot more memory then:
>
> union{
>  sphere{<0,0,0>,5 translate x*2}
>  sphere{<0,0,0>,5 translate x*4}
>  sphere{<0,0,0>,5 translate x*6}
>  sphere{<0,0,0>,5 translate x*8}
>  sphere{<0,0,0>,5 translate x*10}
>  pigment{Green}
> }
>
> I solve this problem by writing it to a .inc file with the #write 
> function. I just didn't expect a big difference in memory usage with 
> the two methods.
>
They should use about the same amount of memory. Case 1 use a little 
memory for the variable, case 2 use some more memory for the source. If 
you increase the count to 500, then case 2 will use more memory: the 500 
individualy defined spheres source code. The alocated memory during 
parse will be the same, to one variable.

Alain


Post a reply to this message

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