AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

smarter char[] and byte[]

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> JVM, native methods and hardware
View previous topic :: View next topic  
Author Message
Roedy Green
Guest





PostPosted: Sun Nov 27, 2011 8:30 am    Post subject: smarter char[] and byte[] Reply with quote



I was disturbed to find out how much time Java spends copying char[]
and byte[]. Most of the time it has composed something and copies it
into a smaller array for future use.

I suggest we invent something that is a cross between a char[] /
byte[] and an ArrayList that would more efficient than either.

For example, let say you have some code that builds a String. It
composes char is a char[], but not quite fill it up. So it copies it
to a char[] just the right size, and puts a reference to it inside the
String.

What I suggest should happen instead is the oversized char[] should be
linked into the String, without copying. Usually the object will die
before the next GC. We have used even less RAM than had we copied.

Let's say this object survives to GC. AT THAT TIME the char array is
shrunk to fit. So you only bother with the copy when it pays off.
--
Roedy Green Canadian Mind Products
http://mindprod.com
How long till someone puts out a car navigator with the realistic
side comments of a real back seat driver.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> JVM, native methods and hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.