Click here to Skip to main content
15,173,818 members
Please Sign up or sign in to vote.
4.75/5 (4 votes)
See more:
HI All,

I have developed a windows application in .net 3.5. While runing the application many times i encounter "out of memory" exception, since my application loads alot of assemblies. However when i observed the process (of the application) in VMMap (http://technet.microsoft.com/en-us/sysinternals/dd535533) i found CLR maps assemblies into the virtual address space twice, which occupies most of the virtual space.

Can anyone please help me out in understanding that why CLR maps the assemblies twice and cosumes important virtual address?

Moreover if there is any workaround available?

I am using Visual studio 2008 (.net framework 3.5).

-Saurabh
Posted
Comments
dasblinkenlight 14-Mar-11 8:36am
   
Does your application load a lot of assemblies statically (e.g. because of referencing many assemblies at compile-time), or does it load assemblies dynamically? Are the assemblies loaded multiple times built by you or by others? Do the assemblies built by others have strong names?
Saurabh_Saxena 14-Mar-11 8:53am
   
Alright i think i have to correct this question a bit :). Yes the application load alot of assemblies statically since its one of the huge product. Well, just create one very simple winodws application which has one textbox and button. You will notice all the assemblies mapped in to process area are twice.
dasblinkenlight 14-Mar-11 12:24pm
   
Do you have multiple copies of the assemblies in question on your computer? For example, an assembly C could be referenced from assemblies A and B, which come from separate projects, and therefore reference the assembly C separately. In this case CLR could not safely assume that the two copies of C represent the same assembly, unless C has a strong name. Do you see strongly-named assemblies loaded twice as well?
Sergey Alexandrovich Kryukov 14-Mar-11 15:27pm
   
What serves you as a proof that the assembly is mapped twice? Is there a case when the same assembly is loaded one time by reference, another time dynamically?
So far, I'm not convinced by your information, but in case this is the fact, it is very important and worth detailed investigation. What was your method.
Please reply, the problem can be very important.
--SA
Saurabh_Saxena 14-Mar-11 15:53pm
   
HI SAKryukov,

These discussion already taken place,but i dont find any solution for the same. It seems microsoft is already aware of the same.Please check the URL, https://connect.microsoft.com/VisualStudio/feedback/details/467560/clr-maps-assemblies-into-the-virtual-address-space-twice .

To reproduce the problem just follow following steps

1. Create one project as class-library (say 'DemoClassLibrary').
2. Add the class (say 'classDemo') in this project, add any string property
3. Create another prject as windows based application
4. Add the reference of class-library ('DemoClassLibrary') project in windows based application
5. Create Instance of 'classDemo' class in windows based application and assign some value to string property
6.Run the application
7. Use VMMap(http://technet.microsoft.com/en-us/sysinternals/dd535533) and select the process, you will find that class-library dll is mapped twice in virtual space

Please let me know if you still find any difficulty or pass me your mail-id i can send the sample application across.

Cheers,
-Saurabh Saxena

1 solution

Just a thought: Have you tried unchecking the "Enable Visual Studio hosting process" in the project's properties/debug section. Since you experience the problem with multiple debug sessions, this process could be the one "remembering" the old references.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900