Re: Do you use a garbage collector (java vs c++ difference in "new")
Chris Thomasson wrote:
"Roedy Green" <see_website@mindprod.com.invalid> wrote in message
news:s7mtv3p1c55bd4v6v2sdgpdl9h8qfdk23n@4ax.com...
On Thu, 10 Apr 2008 20:31:49 -0500, Razii
<DONTwhatevere3e@hotmail.com> wrote, quoted or indirectly quoted
someone who said :
Creating 10000000 new objects with the keyword 'new' in tight loop.
All Java has to do is add N (the size of the object) to a counter and
zero out the object.
[...]
No. What type of counter are you talking about? A distributed counter? A
single global counter? How do the threads interact with the counter? If
you use a single variable, and interlocked RMW instructions, well, then
your going to hit contention on the singular instance of a global
counter. Why not distribute the count, and create two versions of a
interrogate type function that can get approximate counts, or one that
"tries harder"...
To what are you saying no?
Roedy's speaking of a memory pointer, managed by the JVM itself. The
programmer never allocates a "counter" explicitly, they just call on the 'new'
operator. Such an action is always thread local at least until the memory
allocation part of 'new' completes, although the constructor could (likely
foolishly) start a thread after that. Your points have nothing whatsoever to
do with memory allocation in Java, Chris.
Java memory allocation takes a handful or two of machine instructions that
simply increment a pointer in memory. Boom, done. No hunting for suitable
holes.
There's no "count" to "distribute" in that action, whatever the heck you meant
by that.
--
Lew