473,785 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with memory at WTS/Citrix Servern

Hello,

currently we encounter several huge memoryproblems running .NET C#
Applications under Windows Terminal Servers/Citrix. Sometimes the program
claims 100 MB which is not very much at a single PC but a pain in the ass at
a Terminalserver when 20-25 Users start the program (25*100 = 2500 MB).

We made some analysis:

So we build a new project which only contains 2 forms. The first form just
has one button which starts the second form:

private void button1_Click(o bject sender, System.EventArg s e)

{

Form2 frm = new Form2();

frm.ShowDialog( );

}

This second form contains a listview with 10 columns and a button in order
to fill it. After pressing the button the listview is filled:

private void button1_Click(o bject sender, System.EventArg s e)

{

Random rd = new Random();

Cursor.Current = Cursors.WaitCur sor;

ListViewItem item;

string[] s = new string[10];

for (int i=0;i<100000;i+ +)

{

s[0] = rd.NextDouble() .ToString();

s[1] = rd.NextDouble() .ToString();

s[2] = rd.NextDouble() .ToString();

s[3] = rd.NextDouble() .ToString();

s[4] = rd.NextDouble() .ToString();

s[5] = rd.NextDouble() .ToString();

s[6] = rd.NextDouble() .ToString();

s[7] = rd.NextDouble() .ToString();

s[8] = rd.NextDouble() .ToString();

s[9] = rd.NextDouble() .ToString();

item = new ListViewItem(s) ;

this.lvData.Ite ms.Add(item);

}

}

During this the memoryusage rises till 180 MB. If I close the second form
and return to the first one the memory decreases to 100 MB. This value didn't
decrease any more. So we change the code in the first form which opens the
second one:

private void button1_Click(o bject sender, System.EventArg s e)

{

Form2 frm = new Form2();

frm.ShowDialog( );

frm.Dispose(); // NEW Statement

GC.Collect(); // NEW Statement

}

Now the memory changes after closing the second form from 100 MB to 25 MB.
This is much better but still not enough! Why does s single application with
one form and one button still uses 25 MB? At the beginning it just had 8 MB.
Run this program at a WTS by 20 Users and you have 500 MB wasted by a single
form with just one button!

We have also read the 1150 pages of ScaleNet.pdf from MSDN. I was wondering
about this sentence: AVOID CALLING GC.COLLECT. But this was the only way to
reduces the memory in my sampleapplicati on!

How can we solve this problem? Is there any better chance to get rid of this
waste of memory? At a normal PC it does not matter but it is critical at a
Terminal Server.

Thank you very much


Mar 2 '06 #1
3 1909
Please write a small real-world application and run this on a TS, your
conclusion based on this piece of code are not relevant. It's right, you
only have a few UI elements but you are using a lot of memory because you
are filling a listview with 100000 rows of 10 string values each. Also, the
way you fill the list is wrong, it must take ages to fill the list I guess.
Willy.
"Alexander Overmann" <ao@nospamconne x.de> wrote in message
news:44******** *************** @read.news.de.u u.net...
| Hello,
|
| currently we encounter several huge memoryproblems running .NET C#
| Applications under Windows Terminal Servers/Citrix. Sometimes the program
| claims 100 MB which is not very much at a single PC but a pain in the ass
at
| a Terminalserver when 20-25 Users start the program (25*100 = 2500 MB).
|
|
|
| We made some analysis:
|
| So we build a new project which only contains 2 forms. The first form just
| has one button which starts the second form:
|
|
|
| private void button1_Click(o bject sender, System.EventArg s e)
|
| {
|
| Form2 frm = new Form2();
|
| frm.ShowDialog( );
|
| }
|
|
|
| This second form contains a listview with 10 columns and a button in order
| to fill it. After pressing the button the listview is filled:
|
|
|
| private void button1_Click(o bject sender, System.EventArg s e)
|
| {
|
| Random rd = new Random();
|
| Cursor.Current = Cursors.WaitCur sor;
|
| ListViewItem item;
|
| string[] s = new string[10];
|
| for (int i=0;i<100000;i+ +)
|
| {
|
| s[0] = rd.NextDouble() .ToString();
|
| s[1] = rd.NextDouble() .ToString();
|
| s[2] = rd.NextDouble() .ToString();
|
| s[3] = rd.NextDouble() .ToString();
|
| s[4] = rd.NextDouble() .ToString();
|
| s[5] = rd.NextDouble() .ToString();
|
| s[6] = rd.NextDouble() .ToString();
|
| s[7] = rd.NextDouble() .ToString();
|
| s[8] = rd.NextDouble() .ToString();
|
| s[9] = rd.NextDouble() .ToString();
|
| item = new ListViewItem(s) ;
|
| this.lvData.Ite ms.Add(item);
|
| }
|
| }
|
|
|
| During this the memoryusage rises till 180 MB. If I close the second form
| and return to the first one the memory decreases to 100 MB. This value
didn't
| decrease any more. So we change the code in the first form which opens the
| second one:
|
|
|
| private void button1_Click(o bject sender, System.EventArg s e)
|
| {
|
| Form2 frm = new Form2();
|
| frm.ShowDialog( );
|
| frm.Dispose(); // NEW Statement
|
| GC.Collect(); // NEW Statement
|
| }
|
|
|
| Now the memory changes after closing the second form from 100 MB to 25 MB.
| This is much better but still not enough! Why does s single application
with
| one form and one button still uses 25 MB? At the beginning it just had 8
MB.
| Run this program at a WTS by 20 Users and you have 500 MB wasted by a
single
| form with just one button!
|
|
|
| We have also read the 1150 pages of ScaleNet.pdf from MSDN. I was
wondering
| about this sentence: AVOID CALLING GC.COLLECT. But this was the only way
to
| reduces the memory in my sampleapplicati on!
|
|
|
| How can we solve this problem? Is there any better chance to get rid of
this
| waste of memory? At a normal PC it does not matter but it is critical at a
| Terminal Server.
|
|
|
| Thank you very much
|
|
|
|
Mar 2 '06 #2
Dear Willy,
sure the listview costs a lot of memory but this is at form2. If I close
form2 and return to form1 the memory does not get become free completely.

But maybe my "wrong way" of filling the listview is the reason? Tell me how
you would fill it please and I post the results of ths.
Thanx
Alex

btw: Our real-world application currently uses 60MB-150MB for each(!) user
and we also used all those "hints" found in the web:
stringbuilder, do not use boxing/unboxing to often, set ref-types to null,
GC.COLLECT etc.
Thankx

"Willy Denoyette [MVP]" <wi************ *@telenet.be> schrieb im Newsbeitrag
news:O2******** ******@TK2MSFTN GP12.phx.gbl...
Please write a small real-world application and run this on a TS, your
conclusion based on this piece of code are not relevant. It's right, you
only have a few UI elements but you are using a lot of memory because you
are filling a listview with 100000 rows of 10 string values each. Also,
the
way you fill the list is wrong, it must take ages to fill the list I
guess.
Willy.
"Alexander Overmann" <ao@nospamconne x.de> wrote in message
news:44******** *************** @read.news.de.u u.net...
| Hello,
|
| currently we encounter several huge memoryproblems running .NET C#
| Applications under Windows Terminal Servers/Citrix. Sometimes the
program
| claims 100 MB which is not very much at a single PC but a pain in the
ass
at
| a Terminalserver when 20-25 Users start the program (25*100 = 2500 MB).
|
|
|
| We made some analysis:
|
| So we build a new project which only contains 2 forms. The first form
just
| has one button which starts the second form:
|
|
|
| private void button1_Click(o bject sender, System.EventArg s e)
|
| {
|
| Form2 frm = new Form2();
|
| frm.ShowDialog( );
|
| }
|
|
|
| This second form contains a listview with 10 columns and a button in
order
| to fill it. After pressing the button the listview is filled:
|
|
|
| private void button1_Click(o bject sender, System.EventArg s e)
|
| {
|
| Random rd = new Random();
|
| Cursor.Current = Cursors.WaitCur sor;
|
| ListViewItem item;
|
| string[] s = new string[10];
|
| for (int i=0;i<100000;i+ +)
|
| {
|
| s[0] = rd.NextDouble() .ToString();
|
| s[1] = rd.NextDouble() .ToString();
|
| s[2] = rd.NextDouble() .ToString();
|
| s[3] = rd.NextDouble() .ToString();
|
| s[4] = rd.NextDouble() .ToString();
|
| s[5] = rd.NextDouble() .ToString();
|
| s[6] = rd.NextDouble() .ToString();
|
| s[7] = rd.NextDouble() .ToString();
|
| s[8] = rd.NextDouble() .ToString();
|
| s[9] = rd.NextDouble() .ToString();
|
| item = new ListViewItem(s) ;
|
| this.lvData.Ite ms.Add(item);
|
| }
|
| }
|
|
|
| During this the memoryusage rises till 180 MB. If I close the second
form
| and return to the first one the memory decreases to 100 MB. This value
didn't
| decrease any more. So we change the code in the first form which opens
the
| second one:
|
|
|
| private void button1_Click(o bject sender, System.EventArg s e)
|
| {
|
| Form2 frm = new Form2();
|
| frm.ShowDialog( );
|
| frm.Dispose(); // NEW Statement
|
| GC.Collect(); // NEW Statement
|
| }
|
|
|
| Now the memory changes after closing the second form from 100 MB to 25
MB.
| This is much better but still not enough! Why does s single application
with
| one form and one button still uses 25 MB? At the beginning it just had 8
MB.
| Run this program at a WTS by 20 Users and you have 500 MB wasted by a
single
| form with just one button!
|
|
|
| We have also read the 1150 pages of ScaleNet.pdf from MSDN. I was
wondering
| about this sentence: AVOID CALLING GC.COLLECT. But this was the only way
to
| reduces the memory in my sampleapplicati on!
|
|
|
| How can we solve this problem? Is there any better chance to get rid of
this
| waste of memory? At a normal PC it does not matter but it is critical at
a
| Terminal Server.
|
|
|
| Thank you very much
|
|
|
|

Mar 4 '06 #3

"Alexander Overmann" <ao@nospam.cone xt.de> wrote in message
news:44******** *************** @read.news.de.u u.net...
| Dear Willy,
| sure the listview costs a lot of memory but this is at form2. If I close
| form2 and return to form1 the memory does not get become free completely.
|

That's right, this is due to the fact that after you ran the Form2, the CLR
has loaded the framework code for the windows ListView stuff and a buch of
other classes and static variables like strings that are getting interned
(~3MB) but the remaining 25MB is not the problem, the problem is your actual
memory consumption when filling the list. Note that on V2 of the framework
this starts with ~13MB and ends with ~21MB (after a second GC run).

You should never fill a ListView or whatever UI container with that number
of elements.
Why? Well no-one likes to scroll through such a list, it's bad UI design.
Second, memory overhead; you create 1000000 strings objects of 52 bytes each
= 52000000 bytes.
1000000 Listview SubItems of 28 bytes each = 28000000 bytes.
100000 Listview items of 64 bytes each = 6400000
add to that the hashtables used for the listview indexes and you have a
total of 106MB for a single ListView. Note that I'm not counting the randow
doubles(1000000 ) aand the objects added by the framework classes itself.
This accounts for ~200MB workingset usage, imagine this on a TS with 100
users - 200Mb * 100 = 20 GB, or 5GB for 25 users that would be a real
problem.

That's one thing, next the way you fill the list takes ages (>20 minutes) on
v2 of the framework, while you keep the CPU saturated and this on the UI
thread. This is because you fill the list row per row (using Items.Add(..)),
while you should use AddRange. And as a side effect you prevent the GC to
clean-up the garbage in a timely fashion, that's not a problem when you have
plenty of memory, but on a TS that becomes a problem as you noticed.

Willy.

| But maybe my "wrong way" of filling the listview is the reason? Tell me
how
| you would fill it please and I post the results of ths.
| Thanx
| Alex
|
| btw: Our real-world application currently uses 60MB-150MB for each(!) user
| and we also used all those "hints" found in the web:
| stringbuilder, do not use boxing/unboxing to often, set ref-types to null,
| GC.COLLECT etc.
| Thankx
|
| "Willy Denoyette [MVP]" <wi************ *@telenet.be> schrieb im
Newsbeitrag
| news:O2******** ******@TK2MSFTN GP12.phx.gbl...
| > Please write a small real-world application and run this on a TS, your
| > conclusion based on this piece of code are not relevant. It's right, you
| > only have a few UI elements but you are using a lot of memory because
you
| > are filling a listview with 100000 rows of 10 string values each. Also,
| > the
| > way you fill the list is wrong, it must take ages to fill the list I
| > guess.
| >
| >
| > Willy.
| >
| >
| > "Alexander Overmann" <ao@nospamconne x.de> wrote in message
| > news:44******** *************** @read.news.de.u u.net...
| > | Hello,
| > |
| > | currently we encounter several huge memoryproblems running .NET C#
| > | Applications under Windows Terminal Servers/Citrix. Sometimes the
| > program
| > | claims 100 MB which is not very much at a single PC but a pain in the
| > ass
| > at
| > | a Terminalserver when 20-25 Users start the program (25*100 = 2500
MB).
| > |
| > |
| > |
| > | We made some analysis:
| > |
| > | So we build a new project which only contains 2 forms. The first form
| > just
| > | has one button which starts the second form:
| > |
| > |
| > |
| > | private void button1_Click(o bject sender, System.EventArg s e)
| > |
| > | {
| > |
| > | Form2 frm = new Form2();
| > |
| > | frm.ShowDialog( );
| > |
| > | }
| > |
| > |
| > |
| > | This second form contains a listview with 10 columns and a button in
| > order
| > | to fill it. After pressing the button the listview is filled:
| > |
| > |
| > |
| > | private void button1_Click(o bject sender, System.EventArg s e)
| > |
| > | {
| > |
| > | Random rd = new Random();
| > |
| > | Cursor.Current = Cursors.WaitCur sor;
| > |
| > | ListViewItem item;
| > |
| > | string[] s = new string[10];
| > |
| > | for (int i=0;i<100000;i+ +)
| > |
| > | {
| > |
| > | s[0] = rd.NextDouble() .ToString();
| > |
| > | s[1] = rd.NextDouble() .ToString();
| > |
| > | s[2] = rd.NextDouble() .ToString();
| > |
| > | s[3] = rd.NextDouble() .ToString();
| > |
| > | s[4] = rd.NextDouble() .ToString();
| > |
| > | s[5] = rd.NextDouble() .ToString();
| > |
| > | s[6] = rd.NextDouble() .ToString();
| > |
| > | s[7] = rd.NextDouble() .ToString();
| > |
| > | s[8] = rd.NextDouble() .ToString();
| > |
| > | s[9] = rd.NextDouble() .ToString();
| > |
| > | item = new ListViewItem(s) ;
| > |
| > | this.lvData.Ite ms.Add(item);
| > |
| > | }
| > |
| > | }
| > |
| > |
| > |
| > | During this the memoryusage rises till 180 MB. If I close the second
| > form
| > | and return to the first one the memory decreases to 100 MB. This value
| > didn't
| > | decrease any more. So we change the code in the first form which opens
| > the
| > | second one:
| > |
| > |
| > |
| > | private void button1_Click(o bject sender, System.EventArg s e)
| > |
| > | {
| > |
| > | Form2 frm = new Form2();
| > |
| > | frm.ShowDialog( );
| > |
| > | frm.Dispose(); // NEW Statement
| > |
| > | GC.Collect(); // NEW Statement
| > |
| > | }
| > |
| > |
| > |
| > | Now the memory changes after closing the second form from 100 MB to 25
| > MB.
| > | This is much better but still not enough! Why does s single
application
| > with
| > | one form and one button still uses 25 MB? At the beginning it just had
8
| > MB.
| > | Run this program at a WTS by 20 Users and you have 500 MB wasted by a
| > single
| > | form with just one button!
| > |
| > |
| > |
| > | We have also read the 1150 pages of ScaleNet.pdf from MSDN. I was
| > wondering
| > | about this sentence: AVOID CALLING GC.COLLECT. But this was the only
way
| > to
| > | reduces the memory in my sampleapplicati on!
| > |
| > |
| > |
| > | How can we solve this problem? Is there any better chance to get rid
of
| > this
| > | waste of memory? At a normal PC it does not matter but it is critical
at
| > a
| > | Terminal Server.
| > |
| > |
| > |
| > | Thank you very much
| > |
| > |
| > |
| > |
| >
| >
|
|
Mar 4 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
4755
by: James Ng | last post by:
I have posted this to the Citrix Developers' forum and have not heard anything yet. So I'd like to see if any other Java developers have experience this problem with their Java application in a Citrix Published application environment. We are running Citrix XP enterprise feature release 2 on windows 2000 server sp4. We developed a Java application which can catch the "PrintScreen" key event released event correctly in our PC but could...
1
1683
by: Todd | last post by:
I have a .Net windows app running over a Citrix enviornment that normally shows 30 to 50MB of usage according to the server's Task Manager. Our Citrix admin is concerned that this app will register 150MB+ for certain users at certain times and then hold onto this memory. Should we be concerned with this kind of usage? I've read the framework takes more memory than it needs and deallocates as necessary for single .Net applications. ...
0
1429
by: tom | last post by:
Hey All, We are hosting our Access XP application via Citrix and are having some confusion about memory. The Citrix server has 2GB of RAM, and what we are perceiving is that only a fraction of this appears to be utilized by Access/Jet before it starts swapping in and out memory paging files. Is there any way to change this behavior to have our application rely more on RAM first? Thanks,
12
9910
by: Corey Burnett | last post by:
I have a client that has a split database (front-end/back-end). They are also using Access security - MDW file. The front end MDE file, the back end MDB file, and the MDW file are all located on a shared folder on the file server. They have two populations of users - local and remote. *ALL* users currently get to the system via a Citrix login. They log in to Citrix and get a Citrix desktop. Then they start the application via a...
16
2219
by: Wayne Aprato | last post by:
I have several Access 97 databases which are split into front end and back end running off a server. The front end mde is shared by 2 or 3 - absolute maximum of 6 concurrent users. This scenario has been working flawlessly for about 2 years. I am now at a point where these databases need to be converted to Access 2003. I think I read somewhere on this forum that the newer versions of Access are not as tolerant to multiple users...
33
3290
by: DFS | last post by:
An application I wrote has been deployed on Citrix, and the Citrix admin tells me all users run the same .mde file. There aren't a lot of concurrent users, but even 2 could be cause for concern. I think the use of globals is worrisome in this case. Anybody have any experience with Access on Citrix? (Al Kallal already griped me out about globals, but if he has anything new to add I'm all ears).
5
11294
by: Art | last post by:
Hi, We have some applications that run on a Citrix server. I would like to run one of them, a reporting app, from within a VB.net application. If I log into the Citrix server with remote desktop, I can type a command line that will do what I want. My VB.net application is not on that Citrix server. I'm afraid that if I map a drive to the Citrix box and shell out to the reporting app that I'll take it over -- that is, my use of the...
8
4386
by: Blaine Manyluk | last post by:
Greetings... I have some strange problems involving: Access 2000 (9.0.4402 SR-1) Windows 2000 Server 5.00.2195 Service Pack 4 Access apps with Oracle/ODBC back ends One app is a reporting one, and it opens reports (in either View or Print mode) from a master form. The code opens the
12
2095
by: =?Utf-8?B?QXJ0?= | last post by:
Hi, I'm putting together an application in vb.net. I will ultimately need people to be able to run it from home (Normally we're in one office). I can store it on a file server, but this raises the problem of a home user needing the .net framework. I seem to have 2 choices, and have no experience in either. First, since we use Citrix here, I could publish it as a Citrix application.
0
9481
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10155
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9953
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8978
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7502
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.