Question: I am using `msbuild` script to deploy `ssrs` reports. Previously all reports used to be in one folder and I have written a `msbuild` script to deploy these reports to report server. Now we are maintaining reports at folder level such as `customer service, inventory` and `invoice` folders. 

How to deploy these individual folder to report server? In report server also we need folder level hierarchy.

Answer: 
In my opinion the following will be a better way.

`str = s.substring( i,i+k ).intern() ;`
Remove the `new String` part first and move the `String str` out of the loop. We somehow need to make sure that the string returned from `subString` is unique.
Using the `intern` makes Java reuse the same strings. A note for caution though. Using [intern](https://en.wikipedia.org/wiki/String_interning) will slow your code down.

It will save memory though.
Maybe you are using an invalid assumption when you say:

> 
> You can assume it to be sufficiently large, more than 64gb for eg. The problem is with the code.
> 
> 
> 

How many entries are there in the map and what size are they when it blows. Try adding some debug code like:

```
if (map.size() % 50000 == 0) {
            System.out.println(map.size());
}

```

And post more info. The input string size, the size of substrings, the last reported result, and Xmx value being used.