Re: [GD-Linux] Reinitializing the heap
                
                Brought to you by:
                
                    vexxed72
                    
                
            
            
        
        
        
    | 
      
      
      From: Steve B. <sjb...@ai...> - 2001-11-28 00:04:29
      
     | 
| "Josh Adams" wrote:
> The easiest way to get this behaviour would be to write a local
> allocator which offered those semantics.  I did this at one point
> with a head implementation that allowed watermarking.  Basically you
> could make watermarks at various times, and then free all
> still-valid allocations back to the named watermark (yeah, single
> threaded with linear process flows).
That seems dangerous beyond sanity.
If you use *any* library functions, you could end up freeing memory
it still has pointers to...your graphics library, even (in principal) the
C standard library could be using heap memory that you don't know about.
Suppose there was something like:
  void some_glibc_function ()
  {
    static char *pointer = NULL ;
    if ( pointer == NULL )
    {
      pointer = malloc ( 100 ) ;
      precompute_something () ;
    }
    ...do something using the precomputed data...
  }
...that would fail disasterously if you did what you propose.
This kind of dirty trick is common in the games console business - but
those don't have operating systems (well, not that matter) and you can
do this kind of disgusting thing and get away with it.
"Ryan C Gordon" replied:
>> That being said, someone needs to speak reasonably and say that all of
>> this is interesting, but bad, bad practice.
I just flat out don't think it'll work.
>> Shrugging your shoulders and
>> saying "hey, it's a video game after all, so who cares if it's got leaks
>> in the first place and I choose a non portable hack to fix them in the
>> second?" is not only shortsighted, but it says a lot about game coding
>> mentalities that are rampant in the industry.
Yep.  A memory leak is a **BUG** and you should determinedly seek it out
because you don't know what *all* of it's side-effects are until you've
found it.  What might have the obviously visible side effects of leaking
memory might also be corrupting something...who knows?
>> I would recommend that you attack memory problems with the correct tools:
>> dmalloc, ElectricFence, mcheck(), etc. It may save your sanity later on.
Yes.
 
----------------------------- Steve Baker -------------------------------
Mail : <sjb...@ai...>   WorkMail: <sj...@li...>
URLs : http://www.sjbaker.org
       http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net
       http://prettypoly.sf.net http://freeglut.sf.net
       http://toobular.sf.net   http://lodestone.sf.net
 |