Monday, January 16, 2006

My Cave Online - StringBuffer.toString() doesn't share contents in 1.5

My Cave Online - StringBuffer.toString() doesn't share contents in 1.5: "Re: StringBuffer.toString() doesn't share contents in 1.5
It wasn't confusion that made them kill the feature, it was the potential for massive memory leaks that did it in. Check the Sun bug database it's in there. But a quick example would be stuffing a StringBuffer with text from a file and running a regex over it. Your regex finally matches so you say return regex.group(). Now, the substring you matched contains 10 chars of a 1,000,000 char array, which can't get GC'ed because you are holding on to 10 of them."

No comments: