comp.lang.ada
 help / color / mirror / Atom feed
From: James Rogers <jimmaureenrogers@worldnet.att.net>
Subject: Re: is ada dead?
Date: Sun, 08 Jul 2001 03:46:42 GMT
Date: 2001-07-08T03:46:42+00:00	[thread overview]
Message-ID: <3B47D830.830E4E31@worldnet.att.net> (raw)
In-Reply-To: m34rso3ygq.fsf@yahoo.com



"Stephen J. Bevan" wrote:
> 
> James Rogers <jimmaureenrogers@worldnet.att.net> writes:
> > In other words, if
> > you want to loop through all the characters in an existing 1024
> > character String, replacing each one, you will require the creation
> > and garbage collection of 1024 1024 character strings. Since Java
> > characters are all 16 bits, this means that you need to chew up
> > over 2 Megabytes of data to edit a 1024 character String.
> 
> You could do it like that.  However, it would be more efficient to
> turn your String into a StringBuffer, which supports in-place updates.
> Make all the changes you want to the StringBuffer and then turn it
> back into a String.  This way you'd only chew up approximately 3K.

No, this is approximately 6k. Remember that every Java character
requires 2 bytes.

Yes. The Stringbuffer class is much more efficient than the String
class for editing purposes. It is still terribly inefficient 
compared to, for instance, Ada strings.

Remember the extra processing overhead needed to use a StringBuffer
also. Consider the StringBuffer a linked list of characters.
I say this because the StringBuffer is resizable, while the String
class, and Java arrays are not. This means that the StringBuffer
cannot be implemented using an array. First you allocate 
the space necessary to implement a String containing 1024
characters. The memory used is slightly in excess of 2k bytes.
Next you must allocate 1024 characters and associate them with
the StringBuffer object. This is not explicit to the programmer,
because it is done by the methods in the StringBuffer class.
Finally you must allocate another String containing copies of 
each of those StringBuffer characters, another 2k bytes. If the
original String object is now unreferenced you must garbage
collect roughly 2k bytes. You must also garbage collect the
StringBuffer object and the 1024 elements of two byte characters.
The catch to this is that Java does not define what it means
by garbage collection. Some Java garbage collectors do not
defragment memory after collection. Heavy use of a StringBuffer
can result in highly fragmented memory. This may not be a memory
leak, but it can result in the eventual inability to allocate
a needed block of memory.

The StringBuffer is still highly inefficient compared to the 
ability to edit characters in place in a string. Such editing 
requires no memory allocation or deallocation. Neither does it 
require any gratuitous copying to convert from one type to another.
It certainly does not run the risk of fragmenting memory.

Jim Rogers
Colorado Springs, Colorado USA



  reply	other threads:[~2001-07-08  3:46 UTC|newest]

Thread overview: 169+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-05 21:56 is ada dead? tyler spivey
2001-07-05 23:11 ` James Rogers
2001-07-06  0:21 ` Gerhard Häring
2001-07-06  2:31 ` wzm
2001-07-06  7:47 ` Pascal Obry
2001-07-06 12:12 ` Martin Dowie
2001-07-06 21:33   ` Bobby D. Bryant
2001-07-06 14:04 ` Marin David Condic
     [not found]   ` <3B45E0E9.E3E7BB55@nokia.com>
2001-07-06 16:45     ` Marin David Condic
2001-07-06 18:28 ` Robert Dewar
2001-07-06 19:12 ` Lao Xiao Hai
2001-07-07  1:57   ` Adrian Hoe
2001-07-06 21:36     ` Bobby D. Bryant
2001-07-07 10:53       ` Larry Kilgallen
2001-07-07 18:44         ` James Rogers
2001-07-07 21:19           ` String support (was: is Ada dead?) Larry Kilgallen
2001-07-08  3:15           ` is ada dead? Stephen J. Bevan
2001-07-08  3:46             ` James Rogers [this message]
2001-07-08  5:29               ` Stephen J. Bevan
2001-07-09 14:27                 ` Marin David Condic
2001-07-08 11:07             ` Larry Kilgallen
2001-07-08 14:57               ` Stephen J. Bevan
2001-07-08 13:34       ` Me
2001-07-07 18:33     ` James Rogers
2001-07-07 22:41       ` Andrzej Lewandowski
2001-07-08  0:58         ` Larry Kilgallen
2001-07-09  1:33           ` Florian Weimer
2001-07-08  1:45         ` Jeffrey Carter
2001-07-08 17:19           ` Robert C. Leif, Ph.D.
2001-07-08 21:28             ` Larry Kilgallen
2001-07-09  2:46               ` Robert C. Leif, Ph.D.
2001-07-09 10:36                 ` Mandating code quality (was: is Ada dead?) Larry Kilgallen
2001-07-08 10:52         ` is ada dead? Michal Nowak
2001-07-08 22:38           ` Andrzej Lewandowski
2001-07-09  1:20             ` James Rogers
2001-07-09 14:45               ` Marin David Condic
2001-07-09 15:54                 ` Ted Dennison
2001-07-09 20:27                   ` Jerry Petrey
2001-07-09 21:08                     ` Ted Dennison
2001-07-14 16:49                     ` Stefan Skoglund
2001-07-10 23:59                   ` Why " raj
2001-07-14 16:53                     ` Stefan Skoglund
2001-07-14 23:14                       ` James Rogers
2001-07-15 22:57                         ` Stefan Skoglund
2001-07-16 14:00                         ` Trains in the US (was: Why is ada dead?) Ted Dennison
2001-07-10 23:56                 ` Why is ada dead? raj
2001-07-11  2:59                   ` James Rogers
2001-07-09 16:50             ` Michal Nowak
2001-07-15 18:14             ` Lao Xiao Hai
2001-07-16 15:38               ` Marin David Condic
2001-07-16 17:32                 ` Mark Lundquist
2001-07-16 22:18                   ` tmoran
2001-08-01 18:53                     ` "first-mover (dis)advantage" (was Re: is ada dead?) Mark Lundquist
2001-08-02 15:44                       ` Ted Dennison
2001-07-21 16:30                   ` is ada dead? Bertrand Augereau
2001-07-16 18:19                 ` Larry Kilgallen
2001-07-16 18:21                   ` Marin David Condic
2001-07-16 20:14                     ` Gary Scott
2001-07-16 18:26                   ` Mark Lundquist
2001-07-16 21:21               ` Michal Nowak
2001-07-10 23:31         ` raj
2001-07-10 23:32         ` raj
2001-07-10 23:46         ` "garbage dumps are full of superior solutions" raj
2001-07-10 23:47         ` Managers believe that Ada programmers are hard to find raj
2001-07-11  9:38           ` Martin Dowie
2001-07-11 12:39           ` Marc A. Criley
2001-07-11 17:32           ` Jeffrey Carter
2001-07-11 19:05             ` Pat Rogers
2001-07-07 22:37     ` is ada dead? Andrzej Lewandowski
2001-07-08  1:10       ` James Rogers
2001-07-08  1:47       ` Jeffrey Carter
2001-07-08  9:01       ` Pascal Obry
2001-07-08 10:52       ` Michal Nowak
2001-07-08 22:40         ` Andrzej Lewandowski
2001-07-09  1:48           ` James Rogers
2001-07-09 15:11           ` Jerry Petrey
2001-07-09 16:14             ` Al Christians
2001-07-09 19:35               ` Death by analogy Part 1 (was Re: is ada dead?) Michael P. Card
2001-07-09 19:52               ` Death by analogy Part 2 " Michael P. Card
2001-07-09 22:07                 ` Al Christians
2001-07-10  3:38                   ` Michael P. Card
2001-07-10  4:54                     ` Al Christians
2001-07-10 10:54                       ` Robert C. Leif, Ph.D.
2001-07-10 16:58                         ` Al Christians
2001-07-10 17:58                           ` William Dale
2001-07-10 18:39                           ` Michael P. Card
2001-07-10 20:10                             ` Ed Falis
2001-07-10 20:46                               ` Ted Dennison
2001-07-10 20:54                                 ` Ed Falis
2001-07-10 21:15                                   ` Ted Dennison
2001-07-10 21:29                                     ` Ed Falis
2001-07-10 21:10                               ` Al Christians
2001-07-10 21:26                                 ` Marin David Condic
2001-07-10 21:26                                 ` Ed Falis
2001-07-10 21:48                                   ` Ted Dennison
2001-07-10 21:56                                   ` Marin David Condic
2001-07-11  1:59                                     ` Ed Falis
2001-07-11  2:38                               ` DuckE
2001-07-11 21:00                                 ` Ed Falis
2001-07-12  1:42                                   ` DuckE
2001-07-12 10:54                                   ` UML for Ada raj
2001-07-12  8:03                                 ` Death by analogy Part 2 (was Re: is ada dead?) David Humphris
2001-07-13  2:43                                   ` DuckE
2001-07-23 21:53                                     ` Greg Bek
2001-07-20  7:49                                   ` Lao Xiao Hai
2001-07-10 20:26                             ` Ted Dennison
2001-07-10 20:39                             ` Al Christians
2001-07-10 20:42                               ` Ed Falis
2001-07-10 20:53                                 ` Marin David Condic
2001-07-10 21:11                               ` Michael P. Card
2001-07-11  5:25                                 ` Ada and UML raj
2001-07-11  9:40                                   ` David C. Hoos, Sr.
2001-07-13 19:00                                   ` Nick Williams
2001-07-13 19:46                                     ` Ted Dennison
2001-07-17  8:25                                       ` David Humphris
2001-07-16  0:56                                     ` Ken Garlington
2001-07-16  1:57                                       ` Ada and UML - Rational dropping Ada? Jeff Creem
2001-07-16 17:37                                         ` Ken Garlington
2001-07-17 18:59                                       ` Ada and UML Simon Wright
2001-07-23 14:38                                         ` John Kern
2001-08-04  6:29                                           ` Simon Wright
2001-07-11  0:25                             ` Sure FIRM is lost, but really, who cares raj
2001-07-11  0:33                             ` Death by analogy Part 2 (was Re: is ada dead?) Robert C. Leif, Ph.D.
2001-07-10 12:58                     ` John Kern
2001-07-10 13:59                   ` Marin David Condic
2001-07-10  1:21               ` is ada dead? Pat Rogers
2001-07-10  2:29                 ` Al Christians
2001-07-09  1:44       ` Florian Weimer
2001-07-08 21:05         ` Bobby D. Bryant
2001-07-09 10:43           ` One True Language (was: is Ada dead?) Larry Kilgallen
2001-07-09 15:09           ` is ada dead? Ted Dennison
2001-07-14 18:40           ` Stefan Skoglund
2001-07-09  2:37       ` Adrian Hoe
2001-07-07 23:03 ` chris.danx
2001-07-09 15:22   ` Ted Dennison
2001-07-09 16:13     ` chris.danx
2001-07-10  9:02     ` Emmanuel Briot
2001-07-10 10:29       ` Contributing patches to GPL Ada projects (was: Is Ada dead?) Larry Kilgallen
2001-07-10 12:44         ` Emmanuel Briot
2001-07-10 15:24           ` Ted Dennison
2001-07-10 22:33             ` Robert Dewar
2001-07-11  7:46               ` Florian Weimer
2001-07-11 13:07               ` Marc A. Criley
2001-07-11 16:26                 ` Robert Dewar
2001-07-11 13:41               ` Ted Dennison
2001-07-11 16:30                 ` Robert Dewar
2001-07-11 17:45                   ` Ted Dennison
2001-07-14 14:05                     ` Robert Dewar
2001-07-16 15:38                       ` Ted Dennison
2001-07-16 17:37                         ` Ken Garlington
2001-07-11 12:35           ` McDoobie
2001-07-12  8:16             ` Emmanuel Briot
2001-07-14 19:48               ` Stefan Skoglund
2001-07-15  0:16                 ` McDoobie
2001-07-18 16:17                 ` Stephen Leake
2001-07-18 17:55                   ` Pascal Obry
2001-07-19 23:13                   ` Stefan Skoglund
2001-07-20 17:05                     ` Stephen Leake
2001-07-10 13:58       ` is ada dead? Ted Dennison
2001-07-10 17:04       ` Pascal Obry
  -- strict thread matches above, loose matches on Subject: below --
2001-07-06  6:19 Vinzent Hoefler
2001-07-08 12:07 Gautier Write-only-address
2001-07-09  7:39 Vinzent Hoefler
2001-07-09 12:06 ` Jean-Pierre Rosen
2001-07-09  7:40 Vinzent Hoefler
2001-07-09 13:23 Vinzent Hoefler
2001-07-09 13:24 Vinzent Hoefler
2001-07-09 16:20 Vinzent Hoefler
2001-07-10 14:02 Vinzent Hoefler
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox