Memory Consumption Problem

Dec 6, 2008 at 7:30 AM
Edited Dec 6, 2008 at 7:40 AM
We are using Web Service Software Factory to generate our service. We have extended the factory heavily, both design-time and run-time, but here I am only concerned with the former.

Namely, we produce a good deal of source code files based on every service contract model and many of our services have between 10 and 20 of those (we design each service contract of a given service on a different service contract model), or even more in some cases. And some service contracts can be quite extensive.

We have a recipe that can start code generation for all service contract models in the solution and that’s when the problem I describe below becomes most evident.

Aside from the code generation taking too long now, we ran into another problem. On some computers, code generation, or rather the text templating engine powering it, seems to be allocating large amounts of memory (the more code is generated, the more memory is allocated) and not releasing it.

As far as I’ve observed, this behavior varies from computer to computer:
-    When I test it on my old laptop (1.6 GHz, 512 RAM), everything works fine (albeit slow): Visual Studio memory grows to some 130-150 MBs and stays there throughout the entire code generation.
-    On other, better computers (Core 2 Duo, 3 GB RAM), memory grows even up to between 350 and 600 MBs during code generation, but everything seems to be working fine. While on some other computers of the same type, after reaching a certain amount of memory (which again varies from computer to computer) VS crashes.

While I can assume why there is greater memory consumption on computers with more memory, I can’t figure out why it varies so much between computers with virtually same hardware configurations and why on some it eventually crashes VS.

As I mentioned earlier, I tracked down the cause of growing memory problem down to the text templating engine. As far as I know the text templating is done by compiling the transformation class that is then used to process the input parameters. This class is, I believe, created in a separate application domain so it can be released once it is no longer needed?

Had anyone experienced something like this while working with WSSF, some other type of software factory or text templating in general?

I’m open for suggestions how to further diagnose this problem.