Re: C++ vs Java "new" (no flame war please!)



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/>
.



Relevant Pages

  • Re: Id appreciate your opinion(s)
    ... The fact that so much memory is used really doesn't mean you ... When it comes to all of the apps except for ones defined in the ... then I would say that .NET or Java are perfectly fine ... Java and .NET can both do "smart" clients, fat clients, or web-based ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Oracle Personal Edition Sucks!
    ... The tendency to leak memory, run amok and consume the resources ... Now Java apps aren't necessarily bad. ... Oracle just sets a bad example. ...
    (comp.databases.oracle.server)
  • Re: forth and virtual memory
    ... too, maybe even the same order, so ordering the blocks by allocation ... on systems with too little memory ... What Java is known for, and what it actually does, are two distinct ... My measurements indicate that some of the benchmarks (from SpecJVM98, ...
    (comp.lang.forth)
  • Re: What is the fastest method of parsing scheme?
    ... These issues can be eliminated by the use of custom memory allocators ... Any other ideas why Scheme would be faster than C++ and Java for heap ... For example, in my compiler, the procedure ) ...
    (comp.lang.scheme)
  • Re: JVM/Java memory footprint
    ... I found that if I use Java for developing the CLI ... application I will be exhausting the memory of our Application Server ... Just to mention the architecture,users use ... what WHAT specific REASON do you have to make ...
    (comp.lang.java.programmer)