POV-Ray : Newsgroups : povray.off-topic : Found the dynamic optimization things... : Re: Found the dynamic optimization things... Server Time
30 Sep 2024 19:26:02 EDT (-0400)
  Re: Found the dynamic optimization things...  
From: Darren New
Date: 24 Sep 2008 11:48:34
Message: <48da6152$1@news.povray.org>
Warp wrote:
>   When a C/C++ program frees at least a certain amount of memory in Windows
> and Linux, that memory is also freed from the system, and becomes available
> to other programs.

True. On the other hand, if you have a lot of small allocations and you 
can't condense them, you can wind up wasting a lot of memory because you 
have a few bytes allocated on each of dozens of pages. With a compacting 
GC, this situation doesn't occur.

>   If a GC'd program never runs the GC, it will keep all that memory reserved
> even though it doesn't use it. 

I imagine in this case you'd need to implement GC mechanisms that ran 
well. For example, you might force a GC after every N number of new 
pages are allocated.

Now you have me curious - I'll have to look at the code to see when the 
GC gets triggered. It'll be interesting to see how easy that is to find.

> Moreover, a GC'd system often allocates a
> lot more memory than it really needs (because "freed" memory cannot be
> reused until the GC is run).

On the other hand, a compacting GC doesn't have wasted space in the 
pages where the data is stored after a GC runs.

Certainly, a GCed program that doesn't run the GC often enough will 
waste memory, just like a Windows program that doesn't deallocate its 
memory resources when it's finished will use more memory than it needs 
to.  If your video game doesn't clean up the structures for dead aliens 
until you get to the end of the level, you're likely using up more 
memory than you need to.

Doctor, Doctor, it hurts when I do this.

-- 
Darren New / San Diego, CA, USA (PST)


Post a reply to this message

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