Memory Usage in .NET

When you run BDL scripts with .NET method calls, Silk Performer needs to host the Microsoft .NET Common Language Runtime (.NET CLR). Hosting the .NET CLR and loading .NET objects requires additional memory that is used for virtual user processes (containers).

Silk Performer allows you to specify whether each virtual user should run in its own application domain or if all virtual users in a virtual user container should share an application domain. One application domain per user means that all objects from individual virtual users are isolated from the objects of the other users in the same virtual user container.

One application domain per virtual user container means that all objects exist in the same domain and may influence one another. This setting can be changed via your project’s profile settings.

Each additional application domain requires additional memory and administrative overhead by the .NET CLR.

Memory consumption (in MB) is listed below, based on the number of users running in a virtual user process and the application domain setting. This is initial memory consumption when starting a load test (for example, no .NET objects have been loaded).

1 VUser

2 VUser

3 VUser

4 VUser

10 VUser

20 VUser

50 VUser

No .NET Calls (normal BDL Script) 1.668 1.760 1.836 1.904 2.352 3.124 5.484
App Domain/User 5.268 6.644 6.828 6.940 7.916 9.364 13.868
App Domain/Container 5.268 5.404 5.488 5.564 6.036 6.852 9.368

The next table shows memory consumption after loading a simple .NET object. The object defines three methods, but no members.

1 VUser

2 VUser

3 VUser

4 VUser

10 VUser

20 VUser

50 VUser

App Domain/User 5.680 7.404 7.816 8.296 11.000 15.300 28.664
App Domain/Container 5.688 5.812 5.900 6.012 6.620 7.628 10.240

As you can see from the tables above, having one application domain per virtual user requires more memory than does having one application domain per container. The default setting in the project file is one application domain per user. The reason for this is that the objects created by a user cannot influence the objects of other users. Ensure that you won’t run into problems if objects access global resources from within their application domain.

The initial amount of memory needed to host the .NET CLR is about 3.5 MB. The .NET CLR is hosted only once per virtual user container -- this is not influenced by application domain setting.

Memory consumption when loading objects depends on the size of the objects. In the table above, the example loaded object has no members. If you are loading objects with members, memory consumption will be different.

To free up memory from objects that are no longer referenced, call DotNetFreeObject.