C++ vs Java "new" (no flame war please!)
- From: mlw <mlw@xxxxxxxxxxxxxx>
- Date: Sat, 31 Mar 2007 23:34:45 -0400
Do not take anything about this, it is not a flame or troll, while I'm not
new to Java I favor C++. However, I may need to use it in a contract
position, and am concerned that the restrictions it places on application
code.
Take, for instance, this C++ construct:
class foo
{
char *m_name;
....
void * operator new(size_t size, char *string);
}
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. You my argue that this is not a valid concern,
but if you have 10 or 100 million objects, the malloc block overhead,
alone, make this worth while. Hint: This is actually a simplification, some
times malloc is not used at all, and a big array is pre-alocated and work
through it with each new.
Is there a way to create 10 to 100 million objects in Java with a reasonable
system configuration?
.
- Follow-Ups:
- Re: C++ vs Java "new" (no flame war please!)
- From: Mark Rafn
- Re: C++ vs Java "new" (no flame war please!)
- From: Lew
- Re: C++ vs Java "new" (no flame war please!)
- Prev by Date: for doti: pix - camdu lokme - (1/1)
- Next by Date: looking for some hands on experience
- Previous by thread: for doti: pix - camdu lokme - (1/1)
- Next by thread: Re: C++ vs Java "new" (no flame war please!)
- Index(es):
Relevant Pages
|
|