|
How can I place the minimized MDI child windows on the MDI container statusBar just like the windows task bar?
|
|
|
|
|
I have now completed my first real C# program - its a nice system tray thing with a notifier that goes and notifies me when I have new web mail by doing HTTP Post/Gets (these response with an XML reply which I then parse). It also uses the TaskbarNotifier class and the QuickRegistry class that I found in the CodeProject articles (many thanks to the respective authors for these).
My only problem is that the release version of the build consumes 14MB of RAM. I compare this with msnim (which Im sure is written with .NET) and other "long running" processes of the same caliber, and I can only come to the conclusion that I need to reduce the running footprint of my program.
Next Q: What can I do to reduce the running footprint?
I have:
* Changed the build type to "Release"
* Removed TRACE from the build parameters (under Conditional Compilation Constants)
Is there anything else in general I can do, or do I start attempting to rework code at this point to make it lighter weight? (e.g. constant sized strings rather than dynamic strings)
-Adrian
|
|
|
|
|
Hmmm.. The size of your application looks ok for a .NET Windows Forms application. Unfortunately, this is the price you pay for all those neat features.
You can try calling GC.Collect() at strategic points to reduce the memory footprint.
Changing your strings won't help. You can try this[^] and try to locate some points for improvement, but don't expect to go lower than 9~10Mb.
I see dumb people
|
|
|
|
|
How are you checking memory usage? I tried Process.WorkingSet and it seemed to keep eating memory. I'm after a more "lite weight" way to check memory usage in my apps
|
|
|
|
|
If the WorkingSet directly refers to what you have through the task manager, then don't waste your time with it. You've got to check out the "virtual memory" indicator, which is much more trustable.
|
|
|
|
|
Unfortunately, task manager does not report true memory usage, it reports what it "thinks" an app needs - try it out for yourself
load up word or something similar
open task manager and find the instance of the program you have just started
While task manager is open, minimize the app
watch the memory usage drop.
I did this with Word and the memory usage in task manager dropped from 14 meg to 500k - somehow I don't think that it's reporting correct memory here.
Process.WorkingSet is supposed to report the memory usage used by the enitre app (and any component dll's?) but the last time I used it, my memory usage blew out to 110 meg after 6 - 7 hours, and I think this is what caused the high memory usage - this is why I'm after a more "liteweight" of checking memory usage.
|
|
|
|
|
Omega501 wrote:
Unfortunately, task manager does not report true memory usage, it reports what it "thinks" an app needs
That's exactly what I have been telling you. Get rid of the WorkingSet, that's not trustable.
Omega501 wrote:
load up word or something similar
open task manager and find the instance of the program you have just started
While task manager is open, minimize the app
watch the memory usage drop.
when you say "memory usage" you are talking about the WorkingSet, right ?
|
|
|
|
|
.S.Rod. wrote:
when you say "memory usage" you are talking about the WorkingSet, right ?
Nope, as far as I know, WorkingSet reports the correct memory usage of the app. Task manager lies a lot, so it's not something you can trust.
|
|
|
|
|
I don't beleive that Instant Messenger is written with the .NET Framework, so it's probably not a good comparison. For a managed application, 14MB seems reasonable to me. However, if you want to trim your working set, you might try calling this, which might free up 10MB of code that gets used as part of initialization, but might not be needed to run...
Warning: this might not work on Windows 9x. If you've got that in your target configurations, you might want to test for it in Empty below...
using System.Runtime.InteropServices;
namespace PutYourNamespaceHere {
internal class WorkingSet {
internal static void Empty() {
SetProcessWorkingSetSize( -1, -1, -1 );
}
[ DllImport( "Kernel32",
CharSet=System.Runtime.InteropServices.CharSet.Auto,
SetLastError=true)]
private static extern bool SetProcessWorkingSetSize(
int handle, int min, int max);
}
}
Burt Harris
|
|
|
|
|
First, thanks for the cool tip, will try it out in one of my apps.
Is there a sane way of knowing the amount of memory consumed by a .net application, for ex. if I have an application A and application B running, the task manager shows a big chunk of memory used by both these apps.
I'm almost sure the task manager is wrong.
Is it true that the runtime is being shared by these two apps, how do I find out the individual memory consumptions of these two applications.
thanks
Kannan
|
|
|
|
|
I'm pretty sure the runtime will be shared, but it's a little outside my area. Some of the details depend on what OS you are running (9x vs NT based). For this sort of thing, the www.sysinternals.com website has some pretty cool tools. I also highly reccomend their book, as it might provide answers to those sorts of questions.
Burt Harris
|
|
|
|
|
Hello,
NOTE: This is sort of long/detailed.
I know I have been asking a ton of questions lately. Thank you for all of your feedback. I have a custom-drawn listview control that does not highlight the icon while in ListView mode written. I used some of the great painting code provided by Carlos Perez in his UtiltiyLibrary. The problem I am having is that he uses some API SendMessage calls in order to get certain information from the listview. The main thing he is getting is the text of a subitem because when you use Items[1].SubItems[1] (or whatever) you get really weird results. Now the problem I am having is that it doesn't work so well on Win98/ME. I know this is because of the Unicode issue.
I have my SendMessage declared as follows:
[DllImport("user32.dll", CharSet=CharSet.Auto )]<br />
public static extern void SendMessage(IntPtr hWnd, ListViewMessages msg, int wParam, ref LVITEM lParam);
Then it is called with:
SendMessage(Handle, ListViewMessages.LVM_GETITEMTEXTW, row, ref lvi);
ListViewMessages.LVM_GETITEMTEXTW is defined as (LVM_FIRST + 115)
This works great on Win2k. But if I run it on Win98/ME, the Text that is return into lvi is just the first letter. If I change the GETITEMTEXTW to (LVM_FIRST + 45), it will work prefectly on Win98/ME but it does not work correctly on Win2k (just get black bars). I have tried changing the CharSet and making EntryPoint="SendMessageA" on the DLLImport, but nothing works. I have a few other SendMessage calls too that use the Unicode message and I'm afraid that they won't work either.
I have a list of the non-unicode messages, I just need to know to use the same message number is both the Win2k and 98/ME version.
Thanks for reading this really long message.
Jonathan
|
|
|
|
|
To Answer my question for the benefit of others.
From the information that I gave, it was probably practically impossible to answer. It appears that my structure that I had for LV_ITEM had CharSet.Auto set on it. I removed it so that it would be CharSet.Ansi therefore everything concerning converting between ansi and unicode would be taken care of on NT/2000/XP machines. That solved my problem once I set the Messages to be the non-unicode veresion.
|
|
|
|
|
I tried to move a file to a shared fold on another machine within the domain:
File.Move("C:\\test.txt", "\\\\ServerName\\SharedFold\\test.txt");
Every time I got an exception: "Logon failure: unknown user name or bad password." Even if I log on both machine with the same domain user name!
Any one can help me?
RT
|
|
|
|
|
Forgot to note that these codes are in a web app. Win app works OK.
|
|
|
|
|
Does the asp_wp user on the web box have permissions to view/write to that file share?
The actual logged on user's credentials probably aren't even being used because it's running through IIS.
Cheers,
Simon
"The day I swan around in expensive suits is the day I hope someone puts a bullet in my head.", Chris Carter.
my svg article
|
|
|
|
|
In fact I changed the authentication methods for that web site on IIS. I don't use the default IUSER_WORKSTATIONNAME user. Instead I entered a domain user name and password. And I set that shared fold to allow every one can read/write. But still I got "wrong user name or bad password error message".
It really confused me.
RT
|
|
|
|
|
1. Say I have Project A, which references Project B and Project B then references Project C. Why must I add a reference to Projects B AND C in Project A?
2. What can I do to resolve a circular dependency? I have an application that references a class library (separate dll), but that class library requries access to a class in the main application. Hey presto circular dependency
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
Hope this answers your questions...
Even though all of your projects are in the same solution, anything that is outside of a project is still external. Each project would compile down to independant assemblies. So you must create reference by project to make Project A aware of where, exactly, should it go to resolve dependancies. The solution then manages the dependancies and compile hierarchy.
Circular references used to be a problem with prior languages because once you release the object it still hangs around. (memory management would see the existing reference between the two objects and not destroy them) This would be really bad in a case where the object is created many times. So if you create an object and it creates an object and they have circular reference, then when you released the first object it never went away.
Garbage collection now handles circular references better. If you create object B which creates object C which references object B.....when your program ends its' use of object B, it is detected by GC. So it will destroy both object B and C at garbage collection time since the these two objects reference each other but have no parent owner.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
theRealCondor wrote:
Even though all of your projects are in the same solution
My project dependency question relates to situations where the projects are not even in the same solution. Say for example Projects A, B, and C all have there own solution; from the example I gave, Project A would need to add a reference to both Projects B and C, even though it doesn't use any of the classes provided by Project C.
theRealCondor wrote:
Garbage collection now handles circular references better.
Apologies if I wasn't clear in my original post, but my circular dependency problem is one relating also to projects: Project A (producing A.exe) requires a class in Project B (producing B.dll), but Project B requires a class in Project A. Neither project will build until a reference can be added to the other In C++ I can do this with a forward reference, but C# doesn't seem to support this.
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
|
I'm having the same problem with circular references describes above. Two DLLs that reference each other so neither one can compile without the other already being compiled. Could you elaborate on your solution a bit?
|
|
|
|
|
I´ve an instance of a class that is shared among more than one thread. I need this thread to wait (I mean wait, not sleep inside an infinite loop) until a specific property of this object changes (something like a waitforsingleobject). Does anyone know how can I do this in c# ?
Mauricio Ritter - Brazil
Sonorking now: 100.13560 MRitter
"Th@ langwagje is screwed! It has if's but no end if's!! Stupid php cant even do butuns on forms! VISHAUL BASICS ARE THE FUTSHURE!" - Simon Walton
|
|
|
|
|
hi Mauricio,
check out Thread.Join method.
Cheers
Kannan
|
|
|
|
|
Kannan Kalyanaraman wrote:
check out Thread.Join method.
Not extacly what I want... this method will just wait till the thread ends. What I´m trying to accomplish is this:
MyObject = new MyClass();
MyObject.SomeProperty = "XYZ";
while(<here I need something to suspend this thread until
the "SomeProperty" of the class instance changes">);
{
// Do some processing here
}
Any ideas ?
Mauricio Ritter - Brazil
Sonorking now: 100.13560 MRitter
"Th@ langwagje is screwed! It has if's but no end if's!! Stupid php cant even do butuns on forms! VISHAUL BASICS ARE THE FUTSHURE!" - Simon Walton
|
|
|
|