Re: C++ vs Java "new" (no flame war please!)
- From: dagon@xxxxxxxxx (Mark Rafn)
- Date: Mon, 2 Apr 2007 08:18:41 -0700
mlw <mlw@xxxxxxxxxxxxxx> wrote:
Take, for instance, this C++ construct:
void *foo::new(size_t size, char *string)
{
size_t cbstr = strlen(string)+1;
size_t cb = cbstr + size;
foo * t = (foo *) malloc(cb);
char * name = (char *) &t[1];
strcpy(name, string);
t->m_name = name;
}
The above example is a methodology that can be used to reduce the CPU and
memory overhead of malloc.
Trying not to flame C++ here, but I'm glad not to see very much of this kind
of code in Java.
You my argue that this is not a valid concern
In some apps, it is. If you're extremely sensitive to exact memory
allocation, or need hardware access that Java doesn't give you (say, to SysV
shared memory or something), C++ is a good choice. I'd generally recommend to
do the specific sensitive bit in C++ and the rest in Java, but it'll depend
entirely on what the app actually does.
Is there a way to create 10 to 100 million objects in Java with a reasonable
system configuration?
Any VM since 1.4 on modern hardware should not have a problem with this,
unless you're pretty time-sensitive.
--
Mark Rafn dagon@xxxxxxxxx <http://www.dagon.net/>
.
- Follow-Ups:
- References:
- C++ vs Java "new" (no flame war please!)
- From: mlw
- C++ vs Java "new" (no flame war please!)
- Prev by Date: Re: C++ vs Java "new" (no flame war please!)
- Next by Date: Re: C++ vs Java "new" (no flame war please!)
- Previous by thread: Re: C++ vs Java "new" (no flame war please!)
- Next by thread: Re: C++ vs Java "new" (no flame war please!)
- Index(es):
Relevant Pages
|
|