Free is syntactic cyanide. 
Author Message
 Free is syntactic cyanide.

Quote:

> > Which touches every item on the list. But if these are really
> > out of use they are more likely than anything to be paged out.
> > So the loop may trigger a whole cascade of paging operations.

> I've pretty much quit using linked lists for this very reason.
> I use variable-sized arrays instead (with the obvious exceptions
> for giant objects, or lists that need re-ordering, etc).

If I may go off on this tangent...

I'm tempted to do the same, but for the fact that frequent reallocing
for large dynamically sized objects either wastes a lot of memory, or a
lot of cycles copying the object, or both.  

However with modern memory management hardware it doesn't have to be
that way [1].  A clever realloc would treat large (let's say larger than
1 page) objects differently.  On the first realloc such an object would
be copied to a page boundary and given all pages it touches.  On all
subsequent reallocs it just jiggers the MMU.  Look ma, no copying, no
wasted RAM !

Failing that a less elegant scheme would be just to give a large object
a lot of unmapped pages after its end.  That would cut down on the
copying as well and waste only address space, not memory.

Does anyone know if either of these schemes has ever been implemented ?
Any numbers on performance improvement ?  Such dynamic arrays could have
better performance than linked lists.  Do they ?

        Carl Edman

[1] Or even with some ancient forms of memory management hardware.  It
always seemed to me that segments would be ideal for many tasks.  Pity
that the original design limitations of x86 segments made programmers
life such a living hell that nobody else seems to be willing to touch
them again.   Good, clean, simple, flexible and optional(!) segments are
something this hacker has often wished for.  Implementing a BIBOP scheme
is just one other example.



Wed, 05 Jan 2000 03:00:00 GMT  
 Free is syntactic cyanide.


Quote:

>Failing that a less elegant scheme would be just to give a large object
>a lot of unmapped pages after its end.  That would cut down on the
>copying as well and waste only address space, not memory.

>Does anyone know if either of these schemes has ever been implemented ?
>Any numbers on performance improvement ?  Such dynamic arrays could have

You can do this with VirtualAlloc() on NT.  I did it with my postscript
interpreter to prevent high-water marks due to fragmentation of the various
address spaces you have to manage.

We ended up with a customer complaining that my DLL took up too much of the
available address space, and their front end code really, absolutely, must have
1.8Gb of continuous address space, and an interpreter ``obivously'' didn't need
more than a few Mb, so what did I think I was doing?

You can't win....

============================================================================
Ian Kemmish                 18 Durham Close, Biggleswade, Beds SG18 8HZ

Info on Jaws and 5D's other products on http://www.five-d.com
============================================================================
            `My vapourware is better than your vapourware.'



Mon, 10 Jan 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Free is syntactic cyanide.

2. i am developping a free embed RDBMS: polyql

3. Am I free()ing too much?

4. I am seachcing a free pascal editor if someone known a web site just called me

5. String Syntactic Sugar

6. Syntactic coloring tool

7. Questions about c syntactic grammar.

8. Syntactic weirdness? (or is it just me)

9. I am new to programming and am lost

10. free() not freeing?

11. Free, or not free

12. free() - Not freeing!

 

 
Powered by phpBB® Forum Software