IssueRaiser

In reality, performance often matters.

In reality, performance often matters. Then there's no way to avoid needing to understand what the implementation does. The java6 implementation was a big, somewhat well-known gotcha. Read in mb of data in a String, substring a couple kb out, and tada! you're still holding all those mb. You inescapably either: 1 - substring introduces a new string, creating lots of garbage since it's an incredibly common operation, or 2 - substring saves garbage in many cases by having substring return sub-chunks of the full char array, but you will be unable to gc the full string as long as any substring remains reachable

Posted by x0x0 on Jul 10, 2015, 7:01 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.5,500 issues0 comments

hackernews (Other)

In reality, performance often matters.

x0x0Jul 10, 2015, 7:01 PM

In reality, performance often matters. Then there's no way to avoid needing to understand what the implementation does. The java6 implementation was a big, somewhat well-known gotcha. Read in mb of data in a String, substring a couple kb out, and tada! you're still holding all those mb. You inescapably either: 1 - substring introduces a new string, creating lots of garbage since it's an incredibly common operation, or 2 - substring saves garbage in many cases by having substring return sub-chunks of the full char array, but you will be unable to gc the full string as long as any substring remains reachable

Comments (0)

No comments yet. Start the discussion.

Comment on this issue