Re: How: multiple program instances sharing same data
- From: Zytan <zytanlithium@xxxxxxxxx>
- Date: Wed, 14 Nov 2007 03:39:06 -0000
Willy, your posts are a great help.
No it's not, please forget about this nonsense.
Indeed.
Yes, I convert the data read in from the file. Basically just text
data stored in an array of structs internally.
Yes but these array of structs are getting allocated on the GC heap so they
consume private memory.
Right, so this memory isn't shared. I thought it was this data that
was using all the system's RAM, so I reduced it 10 fold, and it
doesn't make that much of a difference. So, now I'm thinking the
Windows Forms themselves are what is using most of the memory, with
all the threads that they make by default. But, I've deleted controls
like crazy, and it seems to make no dent at all in the overall memory
usage :(
Sure, a 1MB exe (MSIL) can consume more than 1MB of code pages, first the
MSIL must be loaded and then it gets run-time compiled to machine code. Both
MSIL and the compiled code are no-sharable, that means that each instance of
the same application will load it's own copy of MSIL and will have it's
private copy of JITted code.
Ok, because the .exe isn't native to my machine, it gets just-in-time
compiled for it, and all of this is repeated for each instance. If I
had my .exe NGEN'd, then this wouldn't be the case, but then the .exe
would run only on the machine I NGEN'd it for, unless I can NGEN it
for the lowest common denominator CPU that it'd be running on, like
Win2000, so it'll run on Win2K and WinXP, and WinVista. Right?
The native DLL's and most of the framework (V2) libraries are Ngen'd, so
they are shared amongst the instances.
I see, I was just assuming ALL of the framework (I use NET 2.0) was
shared.
Most of the framework libraries are copmpiled (ngen'd) and as such they are
share, but their MSIL must be loaded anyway, the CLR needs their metadata at
run-time, also some security and versioning constraints may prevent ngen'd
methods to run , so these need to get JIT compiled.
Ah.
Perfmon and Process Explorer all use the same prerf. counters, so you may
use Process Explorer as long as we are talking about the same counters there
is no problem.
Ok, sure.
What counts here is the Private part, so you should watch the Private
Process counters for your process. The GC heap is part of the private
memory
of a process, the amount of memory you consume from the GC heap depends
on
your allocation scheme, the more and the larger the objects you create
,the
larger the GC heap grows and consequently the larger your Private bytes.
Ok, my private bytes usage is still very high (> 20 MB). But it could
be high just because GC has not cleaned up, right?
I could probably reduce the stack space by half or more, I bet,
without causing problems, I forgot about that. I'll have to see how I
can change that.
You can't do this for the 3 threads created by the run-time, you can only
change the default size of the stack of the threads you create explicitely.
Right.
I've seen a simple do nothing .NET app take 10 MB
Yep, all depends on what you call a .NET app., a console application takes
less than a Windows Forms app. It also depends on the version of the
framework, newer version have larger System and Mscorlib libraries.
I am talking about a Windows NET App, for 8 to 10 MB. Console uses
about half, 5 MB, for a "do nothing". This is why I may remove the
GUI completely, just to save 5 MB each. I am running .NET 2.0, btw.
So, I would suggest you to start to:
- measure the Virtual bytes consumed by a single instance.
- NGEN the exe and measure again, if the Virtual bytes is considerably
lower
keep using the Ngen'd image in your scenario, else forget them.
Is NGEN "Native Image Generator"?
Yep.
Use it whenever you need to run several instances of the same application,
it produces sharable code images (see above). You can't live without it when
running on Terminal Server for instance.
I still haven't tried this, yet, and I will when I find some time, and
report back here.
Well try with ngen first. And watch memory consumption in Process Explorer.
Thanks for all your help, Willy!!!
Zytan
.
- Follow-Ups:
- References:
- How: multiple program instances sharing same data
- From: Zytan
- Re: How: multiple program instances sharing same data
- From: Peter Duniho
- Re: How: multiple program instances sharing same data
- From: Zytan
- Re: How: multiple program instances sharing same data
- From: Peter Duniho
- Re: How: multiple program instances sharing same data
- From: Zytan
- Re: How: multiple program instances sharing same data
- From: Willy Denoyette [MVP]
- Re: How: multiple program instances sharing same data
- From: Zytan
- Re: How: multiple program instances sharing same data
- From: Willy Denoyette [MVP]
- Re: How: multiple program instances sharing same data
- From: Zytan
- Re: How: multiple program instances sharing same data
- From: Willy Denoyette [MVP]
- How: multiple program instances sharing same data
- Prev by Date: Re: NT Authentication not getting passed to business objects
- Next by Date: Re: How: multiple program instances sharing same data
- Previous by thread: Re: How: multiple program instances sharing same data
- Next by thread: Re: How: multiple program instances sharing same data
- Index(es):
Relevant Pages
|