Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: C++ Memory ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 9 of 41 Topic 9525 of 9831
Post > Topic >>

Re: C++ Memory Management Innovation: GC Allocator

by Lance Diduck <lancediduck@[EMAIL PROTECTED] > Apr 22, 2008 at 11:17 AM

On Apr 21, 10:43 pm, marlow.and...@[EMAIL PROTECTED]
 wrote:
> On 21 Apr, 19:13, xu****wei <xu****we...@[EMAIL PROTECTED]
> wrote:
> I took a quick look with particular interest
> in what you have to say about scoped allocators.
> It seems to me that there is some overlap with
> what you are doing and the work by Pablo Halpern in
> his N2523 submission to WG21 entitled "The Scoped Allocator
> Model".
Seehttp://www.open-std.org/JTC1/SC22/WG21/docs/papers/2008/n2523.pdf
>
> IMO Pablo's proposal is more thought through.
> I recommend you take a look.
Pablo doesnt actually propose any allocator. It only mentions a
technique for applying allocators to containers. The only "scoped
allocator" in there is a wrapper around the system allocator.
Pablos work's doesnt mention anything on how to write allocators that
could be scoped. Rather, that if they could be written then this is
how to pass them from one container to another.
And that is the rub-- writing an allocator that could be "scoped" is
very hard indeed. The stated intent of "scoped allocators" is to
change the semantics of STL "regular type" such that any property that
does not contribute to operator== is a runtime policy, instead of
compile time policy. So as such it has little to do with allocators.
It is just that in std containers the allocator is the only thing that
is a policy that does not constribute to operator==.
So OK, now I have a way to propogate allocators from one container to
another. Now there are two questions 1) write a non trivial allocator
that *could* be scoped, and 2) just what problem am I solving by
passing this allocator instance from one container to the next?

xu****wei's work is far more relevant, in that it actually presents
something useful. It is not ready to be standardized, but I am
personally interested in writing up a few allocators for
standardization


> One final point, it seems to me that there is a need
> to bear thread safety in mind. You just say "it's not
> needed". Can you explain why please?

If you look at
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2486.pdf
page three you will see a example of this usage. The idea is this
void * threadfunc(void*){

     std::list<X> x;//assume X allocates no memory
     x.resize(10000);
}
now, when I start up N threads, the list instances *should* be
independent, but this does not happen. Rather, they contend via their
allocator.
So the idea is this
void * threadfunc2(void*){
     SpecialAlloc sa;//grab memory from stack, or in big chunks from
the heap
     std::list<X, SpecialAlloc > x(sa);
     x.resize(10000);
}
Now each thread is isolated, nor does SpecialAlloc need to be thread
safe.

The difference can be dramatic: See
http://groups.google.com/group/comp.lang.c++.moderated/browse_thread/thread/a1eaab58c5bb390c/b763830e33a45985?hl=en&tvc=2#b763830e33a45985
for a test I did. The formatting is not the best, but you can get the
idea. In this case I used a lock-free allocator, but when I repeated
the test using something like SpecialAlloc, I got better performance
still.


-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 41 Posts in Topic:
[Proposal for ISO C/C++] C++ Memory Management Innovation: GC A
xushiwei <xushiweizh@[  2008-04-21 12:13:18 
Re: [Proposal for ISO C/C++] C++ Memory Management Innovation: G
"Chris Thomasson&quo  2008-04-21 15:39:15 
Re: [Proposal for ISO C/C++] C++ Memory Management Innovation: G
"Chris Thomasson&quo  2008-04-21 16:13:16 
Re: [Proposal for ISO C/C++] C++ Memory Management Innovation: G
Alberto Ganesh Barbati &l  2008-04-21 20:43:17 
Re: C++ Memory Management Innovation: GC Allocator
marlow.andrew@[EMAIL PROT  2008-04-21 20:43:18 
Re: C++ Memory Management Innovation: GC Allocator
Lance Diduck <lancedid  2008-04-21 20:43:17 
Re: C++ Memory Management Innovation: GC Allocator
xushiwei <xushiweizh@[  2008-04-22 00:08:55 
Re: [Proposal for ISO C/C++] C++ Memory Management Innovation: G
"Chris Thomasson&quo  2008-04-22 10:52:14 
Re: C++ Memory Management Innovation: GC Allocator
Lance Diduck <lancedid  2008-04-22 11:17:48 
Re: C++ Memory Management Innovation: GC Allocator
xushiwei <xushiweizh@[  2008-04-22 11:17:25 
Re: C++ Memory Management Innovation: GC Allocator
"Chris Thomasson&quo  2008-04-22 11:13:27 
Re: C++ Memory Management Innovation: GC Allocator
"Chris Thomasson&quo  2008-04-22 15:19:26 
Re: C++ Memory Management Innovation: GC Allocator
"Chris Thomasson&quo  2008-04-22 15:19:18 
Re: C++ Memory Management Innovation: GC Allocator
xushiwei <xushiweizh@[  2008-04-22 15:22:50 
Re: C++ Memory Management Innovation: GC Allocator
xushiwei <xushiweizh@[  2008-04-22 15:43:17 
Re: C++ Memory Management Innovation: GC Allocator
"Chris Thomasson&quo  2008-04-22 22:26:21 
Re: C++ Memory Management Innovation: GC Allocator
"Chris Thomasson&quo  2008-04-22 22:25:42 
Re: C++ Memory Management Innovation: GC Allocator
xushiwei <xushiweizh@[  2008-04-22 22:32:36 
Re: C++ Memory Management Innovation: GC Allocator
Francis Glassborow <fr  2008-04-23 14:13:19 
Re: C++ Memory Management Innovation: GC Allocator
xushiwei <xushiweizh@[  2008-04-23 14:43:18 
Re: C++ Memory Management Innovation: GC Allocator
"Chris Thomasson&quo  2008-04-24 01:43:35 
Re: C++ Memory Management Innovation: GC Allocator
"Chris Thomasson&quo  2008-04-25 03:42:49 
Re: C++ Memory Management Innovation: GC Allocator
xushiwei <xushiweizh@[  2008-04-25 10:47:43 
Re: C++ Memory Management Innovation: GC Allocator
"Stephen Howe"   2008-04-25 10:48:18 
Re: C++ Memory Management Innovation: GC Allocator
xushiwei <xushiweizh@[  2008-04-25 10:47:13 
Re: C++ Memory Management Innovation: GC Allocator
xushiwei <xushiweizh@[  2008-04-25 10:45:25 
Re: C++ Memory Management Innovation: GC Allocator
xushiwei <xushiweizh@[  2008-04-25 10:44:50 
Re: C++ Memory Management Innovation: GC Allocator
"Chris Thomasson&quo  2008-04-25 16:15:02 
Re: C++ Memory Management Innovation: GC Allocator
Yongwei Wu <wuyongwei@  2008-04-28 15:58:48 
Re: C++ Memory Management Innovation: GC Allocator
xushiwei <xushiweizh@[  2008-04-28 23:26:31 
Re: C++ Memory Management Innovation: GC Allocator
xushiwei <xushiweizh@[  2008-04-28 23:27:55 
Re: C++ Memory Management Innovation: GC Allocator
"Chris Thomasson&quo  2008-04-29 17:43:31 
Re: C++ Memory Management Innovation: GC Allocator
xushiwei <xushiweizh@[  2008-04-30 04:13:27 
Re: C++ Memory Management Innovation: GC Allocator
xushiwei <xushiweizh@[  2008-04-30 04:13:33 
Re: C++ Memory Management Innovation: GC Allocator
xushiwei <xushiweizh@[  2008-04-30 17:03:54 
Re: C++ Memory Management Innovation: GC Allocator
"Chris Thomasson&quo  2008-04-30 21:55:29 
Re: C++ Memory Management Innovation: GC Allocator
Michael Kilburn <crusa  2008-05-06 08:22:59 
Re: C++ Memory Management Innovation: GC Allocator
"Chris Thomasson&quo  2008-05-06 08:20:19 
Re: C++ Memory Management Innovation: GC Allocator
"Chris Thomasson&quo  2008-05-07 00:31:29 
Re: C++ Memory Management Innovation: GC Allocator
xushiwei <xushiweizh@[  2008-05-07 11:03:52 
Re: C++ Memory Management Innovation: GC Allocator
xushiwei <xushiweizh@[  2008-05-08 03:28:29 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 2:49:55 CDT 2008.