|
ok, now it is clear.
Thank you
"Tutti sanno che una cosa è impossibile da realizzare, finchè non arriva uno sprovveduto che non lo sa e la inventa"
(Albert Einstein)
|
|
|
|
|
hi all,
Recently I devised this bit of code (C#) that works wonders for the memory usage reported in task manager:
Process currentProcess = System.Diagnostics.Process.GetCurrentProcess();
currentProcess.MinWorkingSet = currentProcess.MinWorkingSet;
With one of my more complicated programs, this reduced the initial memory usage (measured once the form loaded completely) from 34690 KB to 8980 KB (!).
I've tried various other solutions, most of which rely on forcing a garbage collection or reducing the process' working set to the minimum working set. I found neither to be very effective. I've never seen this approach anywhere else (small wonder - who would think that setting a value to itself would make such a difference?!).
I haven't had time to research why/how this code works, but this solution changes no values and has an immediate effect (just like minimizing and restoring a .NET program does). Place it in your code after your form initializes and watch your memory usage go down!
Hope this helps someone!
|
|
|
|
|
|
And the working set is precisely what I want to reduce, not just the specific amount that the app is actually using but the entire chunk of memory that the runtime reserves. That's what makes a difference from an outside perspective.
|
|
|
|
|
Maybe, but how much slower is your application when it needs more memory from somewhere and has to ask for more, rather than just use some from its reserve.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
Notice though that the runtime has no problem reducing the memory reserve when you minimize and restore an application, so apparently there is an excess available. As discussed elsewhere, at startup the runtime needs a larger amount of memory, but not so much once everything has loaded, so reducing the working set after initialization is a reasonable solution.
|
|
|
|
|
gonzotuna wrote: who would think that setting a value to itself would make such a difference?!
Because your not. You are setting a property. And a property is just syntactic sugar for a specify style of method(s). The getter and setter of a property actually become the methods get_PropertyName() and set_PropertyName(PropertyType value).
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
|
|
|
|
|
I was actually remarking on the fact that the side effect of setting this specific property to itself would be something so drastic/unexpected, not on the fact that setting a property can have side-effects.
I discovered this memory phenomenon quite by accident as I was experimenting, rather than by deducing what methods to call, etc. I haven't taken the time to dig into what's going on under the covers, but I think it's pretty cool and I'm surprised/glad I stumbled upon it. That's all I meant.
|
|
|
|
|
In the modern age of AUTOMATIC memory management, why is this even a concern?????
Never once have I considered the memory reserved by the framework to be a problem. I've had a few customers ask, and with a quick explanation of how the .NET Framework starts out reserving more memory than it actually needs for it's self-tuning performance, and releasing it back to Windows when Windows demands it, the issue is dropped.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
However, it seems that initially the .NET framework reserves even more memory than it needs to have in reserve for performance reasons. Ever notice how the total memory usage drops dramatically when minimizing and then restoring? If that caused a drop in performance, then we would have to advise everyone using our software that in order to maximize performance they should never minimize the app, explaining that it's just a quirk of the runtime
Is this an important issue? Not really, at least technologically speaking. It's just one of aesthetics. And pretty numbers speak loudly, so if I can provide a product that works, performs well, and has lower apparent memory consumption as well, I'm going to. Especially since I can do it (well, the memory consumption thing at least ) with one line of code.
|
|
|
|
|
gonzotuna wrote: Ever notice how the total memory usage drops dramatically when minimizing and then restoring?
We all have. It also just doesn't matter, since when Windows wants the memory back, the runtime is more than happy to return it.
gonzotuna wrote: And pretty numbers speak loudly
Only if the numbers actually mean something. If the customer wants an app based on "pretty numbers", that's a customer I don't want. I deal in meeting the customers functionality requirements, not the b/s they think they want and don't really understand. I don't waste my time "lying" to the customer about the memory requirements of their app. If they're equipment is so tight on memory, it usually means their checkbook is just as tight and their payment will show up 6 months late.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Once you minimize .NET application or set this property, memory swapped to disk which increase page faults and decrease application's performance. Working set is misleading parameter for .NET applications memory usage.
Read this:
How much memory does my .NET application use?
|
|
|
|
|
I have a Vb Scripting problem with .NET C# application and also
in Asp.NET.
I have written COM component in VC 6.0 , which execute a VBScript
and return a Recordset.
This componet is perfetly working with VC 6 ,VB 6 applications
but it does not work with .Net
the component is which exposes an interface method
GetCustAdoRecordset
{
========= do the script code here
}
CMyScriptSite::public IActiveScriptSite
{
}
..........
iActiveScript->AddNamedItem(L"MyScriptExicuter", SCRIPTITEM_ISVISIBLE
| SCRIPTITEM_ISSOURCE | SCRIPTTEXT_ISPERSISTENT)
.......
this class is my event handling class
CMyScriptExecuter::public CCmdTarget
{
...
...
// here gobal variables are set and passed to the script engine
BEGIN_DISPATCH_MAP(CMyScriptExecuter, CCmdTarget)
//{{AFX_DISPATCH_MAP(CMyScriptExecuter)
DISP_PROPERTY(CMyScriptExecuter, "MycustTime", m_custTime, VT_DATE)
DISP_PROPERTY_EX(CMyScriptExecuter, "TestCount", GetTestCount,
SetNotSupported, VT_I4)
DISP_FUNCTION(CMyScriptExecuter, "mymethod", mymethod, VT_EMPTY,
VTS_BSTR)
...
//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()
}
The above message map code is not executing while running from .net.
Can u kindly give a solution for this, is it a .net problem or any
thing else
===============================
thomachanpv
|
|
|
|
|
This may be a dumb question, but is there a WinForms equivalent of the good old CStatic control used to create lines (and rectangular areas)?
Thanks,
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
|
Yes, I saw this[^] which looks quite nice. I'm a bit surprised why MS excluded the static frame control in WinForms.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Use a label. Set height (if horizontal line) or width (if vertical line) to 2 or 3. Set style to 3d and this will do the trick.
- Malhar
|
|
|
|
|
Thanks (as always!). I'll try this approach.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
How a windows and web pages are Executed in .Net Framework
using c#.net
sowjanya kumar
|
|
|
|
|
Could you clearify what you mean? I understand that you are interrested in the execution of something, but it's unclear if you like to execute something, or if want to know how the execution works.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
I've just exported my VS2003 project to VS2005. The First thing that troubled me is the performance issue with DataView.RowFilter which is almost 10 times slower in .NET 2.0 !!!
I have the same problem with BindingSource.Filter (which of course I believe uses the RowFilter anyways), then I've made no modifications to the project, meaning (using DataView.RowFilter) and still have this problem (10 secs for somefield Like '%something%') for 70000 Rows, which in NET 1.1 is something like 1 sec.
Thanks.
|
|
|
|
|
Hi guys,
I am working a .NET windows application using C#. I have placed a
web browse control in my Windows Form in order to show many types of documents like word doc, text file, ms excel sheet, images or even flash animation etc. There are three panels in this Form. On the left panel there's a Directory tree just like we see in Windows Explorer. The Top panel contains a list of documents in the currently selected directory. I have placed the web browser control in the third panle which is right below the top panel. When the user selects a document (word, excel etc.) it is opened and viewed in the browser control. So far so good. Now the problem occurs when the user selects a document and it is opened for view and he wants to delete it by using the shortcut menu option which is provided by me. The system throws
an exception when i attempt to delete this document from the os directory and says like "The file is in use by another process.". This occurs even if the user selects another document and the application attempts to delete the 'previously' selected document again. This is for sure that the process which is running my app has not yet destroyed the handle of the document, but i don't know how to destory it. I guess the only solution could be P/Invoke but don't know which API functions have to be used. Anybody could help getting rid of this?
thanks
bABURmAN
|
|
|
|
|
Hi,
I have a windows form application with a BackgroundWorker. The user has to stop the backgroundWorker by clicking a button. I would like to indicate that it is still running by using some kind of (continuous ?) progress bar (like the progress bar appearing when Windows XP starts). Is there any easy way to implement this?
Thanks in advance.
|
|
|
|
|
If you just want to create a progress bar that never ends - i.e. you don't know how long the background thread is going to take, then this[^] article might help you (or this[^] one for C#)
Cheers,
Will H
|
|
|
|
|
hi,
i added xpdfviewer control to the vb.net proj. But unable to handle the events of control. Is there any importstatement should i add.
raj
|
|
|
|