Regards, Fawad Ali.
Software Engineer, Stafona Inc. - My Blog
Regards, Fawad Ali.
Software Engineer, Stafona Inc. - My Blog
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
fred rosenberger wrote:Concatenating strings like this is a bad idea. Unless they have changed it, a line like this:
String seriesName = tableNameArray[i] + ":" + databaseNameArray[j] + ":" + accountNameArray[k] ;
will actually cause FOUR strings to be created. It does each "+" sequentially, building intermediate strings as you go. so you get "i:", then "i:j", then "i:j:", then "i:j:k".
fred rosenberger wrote:since you have arrays that are 1000 elements each, you are creating 4 BILLION new strings. I'm not surprised you are running out of memory.
fred rosenberger wrote:What is it you need to do with these once you build them? do you really need them all?
Mike Simmons wrote:
fred rosenberger wrote:Concatenating strings like this is a bad idea. Unless they have changed it, a line like this:
String seriesName = tableNameArray[i] + ":" + databaseNameArray[j] + ":" + accountNameArray[k] ;
will actually cause FOUR strings to be created. It does each "+" sequentially, building intermediate strings as you go. so you get "i:", then "i:j", then "i:j:", then "i:j:k".
I don't think that's correct.
I get Java heap space when I add other calculations into the inner loop.
Regards, Fawad Ali.
Software Engineer, Stafona Inc. - My Blog
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
|