The Artima Developer Community
Sponsored Link

Java Buzz Forum
Beware of Java string memory allocation

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Kevin Dangoor

Posts: 1101
Nickname: tazzzzz
Registered: Jul, 2003

Kevin Dangoor is a developer with JSTOR
Beware of Java string memory allocation Posted: Apr 27, 2005 10:59 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Kevin Dangoor.
Original Post: Beware of Java string memory allocation
Feed Title: Blue Sky On Mars
Feed URL: http://www.blueskyonmars.com/feed/?cat=8%2C13%2C14
Feed Description: Kevin Dangoor's Weblog of Technology, Entertainment and Life - Java only feed. For all articles, check out http://www.blueskyonmars.com
Latest Java Buzz Posts
Latest Java Buzz Posts by Kevin Dangoor
Latest Posts From Blue Sky On Mars

Advertisement

Charles Miller and other Atlassian folks were digging into a memory issue and found out that memory allocation and garbage collection for Strings and StringBuffers may not be what you're expecting. The main thrust of it is that there are some optimizations to speed the common cases that can result in considerable memory waste if you're not aware of the implementation. (For example, if you have a StringBuffer with a 32K capacity and do a toString on it, that new String will take up 32K of memory even if you only had 1 byte in the StringBuffer.)

To me, that actually sounds like a bug. It's probably worth a couple microseconds (or less) to see if the data is significantly smaller than the allocated space and then do a copy if that's the case.

Read: Beware of Java string memory allocation

Topic: [Apr 21, 2005 02:04 PDT] 5 Links Previous Topic   Next Topic Topic: Respresentational State

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use