|
The values returned by those functions are snapshots, they don't change dynamically.
Regards
Senthil
My Blog
|
|
|
|
|
I realize they are shapshots, I took the readings of both at the exact same time, the amount of memory used is not changing. The problem is none of the functions in .NET seem to give me the same amount of memory Windows Taskmanager does. I checked it for all processes running on my machine, and taskmanager gives different results then .NET every time for me.
Thanks
|
|
|
|
|
Hi, I have the following problem:
I need to set the property of a child control of a form, but from an external form. The truth is i have no idea on how to procced to do this,
- do I need to make the owner form aware of the event occured in the external form in order to reflect the change? (change this property)
- or somehow i can refer to the the instance of the owner form from the external form so i can change this property?
Either ways i dont know how to do this, as you can see I'm lost
PS: I've asked on many forums and newsgroups and noone replies me!, I'm hoping for some codeproject geeks to show up
|
|
|
|
|
please tell me . microsoft visio 's document where store the all information of document. like if i give custom properties of document where it save internally . can i see it witout open visio and other property who create it
.is it save any table
freetoyoula
|
|
|
|
|
I have been beating myself up over trying to locate what I thought was a memory leak in MY code but based upon what I have seen I can't be sure that it IS my fault or something strange with DOTNET. Someone here please feel free to enlighten me on this one.
The code to reproduce is very simple. Done in VB.NET (please no language based flames here - I am already working up a C# version just to be safe ) , One form with a button on it called cmdStart. Here is the code behind the form:
Public Class Form1
Inherits System.Windows.Forms.Form
Dim t1 As System.Threading.Thread
Dim t2 As System.Threading.Thread
Dim t3 As System.Threading.Thread
Dim t4 As System.Threading.Thread
Dim t5 As System.Threading.Thread
#Region " Windows Form Designer generated code " 'This has been clipped out for brevity here
Private Sub ThreadWorker()
Do
Debug.WriteLine("Thread Enter. [" & System.Threading.Thread.CurrentThread.Name & "]")
System.Threading.Thread.CurrentThread.Sleep(1000)
Debug.WriteLine("Thread exit [" & System.Threading.Thread.CurrentThread.Name & "]")
Loop
End Sub
Private Sub cmdStart_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdStart.Click
t1 = New System.Threading.Thread(AddressOf ThreadWorker)
t1.Name = "T1"
t1.IsBackground = True
t1.Start()
t2 = New System.Threading.Thread(AddressOf ThreadWorker)
t2.Name = "T2"
t2.IsBackground = True
t2.Start()
t3 = New System.Threading.Thread(AddressOf ThreadWorker)
t3.Name = "T3"
t3.IsBackground = True
t3.Start()
t4 = New System.Threading.Thread(AddressOf ThreadWorker)
t4.Name = "T4"
t4.IsBackground = True
t4.Start()
t5 = New System.Threading.Thread(AddressOf ThreadWorker)
t5.Name = "T5"
t5.IsBackground = True
t5.Start()
End Sub
End Class
Now, you ask what the problem is here? It appears to me that there is a memory leak afoot.At least according to perfmon.
When I monitor the privateBytes for the test app running these threads and sample every 60 seconds I get a very definite memory increase shown.
My question here is WHY?!? My thread is not creating any resources unless you count anything allocated internally by the framework to perform the debug prints. I am testing this running debug build of the app and to be honest I have not tested a release build yet so I cannot comment on what those results are.
Now, keep in mind that my app is MUCH more complicated than this, but I am seeing the same results here as I am in my app. I thought originally that I was seeing some memory issues because I was creating a clone of a few hashtables inside my threads and I thought perhaps that was causing some GC issues but now I am not so sure. In fact when I ran my app with all the internals of the threads commented out except for the debugs and sleeps as I have here I still see the apparent memory creep.
Can ANYONE explain to me what I am seeing here?
Am I going nuts?
I have to admit that I am by no means a threading master yet but this seems pretty basic to me.
The even stranger part is that, while I am typing this in I happened to look at perfmon and see that it appears to have eventually leveled off after about 14 minutes. The memory appears to have gone from 6654720 to approx 7772000. That is a growth of 117280 bytes. Not allot but I still don't understand why the memory is growing. Can this all be explained away by GC? Seems a bit odd since I am not allocating anything in my app on a cyclic basis.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
I suggest you read Joseph Newcomer's excellent article How Big Is My Program?[^] Written for C++ apps, it still applies heavily to .NET applications.
The 'Mem Usage' column in Task Manager - which is the same as the 'Process: Working Set Size' counter in perfmon/System Monitor - shows the amount of physical memory currently allocated to your process. It's not quite that simple, though, as it includes all shared items (such as code in DLLs loaded into your process) that have been referenced recently.
The GC heap follows a fairly common pattern of making virtual memory allocations but not releasing those allocations back to the OS unless memory pressure or the amount of free memory is moderately high. This saves time in making allocations - altering the virtual memory map requires calls into kernel mode. So you'll tend to see the working set grow, in the general case.
Finally recall that a thread is not free. Memory must be allocated for the thread's user- and kernel-mode stacks and for any other per-thread data.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Mike Dimmick wrote:
I suggest you read Joseph Newcomer's excellent article How Big Is My Program?[^] Written for C++ apps, it still applies heavily to .NET applications.
Thanks for that.. I will be sure to check into it.
Mike Dimmick wrote:
The GC heap follows a fairly common pattern of making virtual memory allocations but not releasing those allocations back to the OS unless memory pressure or the amount of free memory is moderately high. This saves time in making allocations - altering the virtual memory map requires calls into kernel mode. So you'll tend to see the working set grow, in the general case.
yeah, I figured it might end up being something like this but I was ammazed to see it take so long. I ran an overnight test (7 hours) and did end up seeing where the memory was reclaimed after 6 hours. I just figured that GC would have an effect quicker than that.
Mike Dimmick wrote:
Finally recall that a thread is not free. Memory must be allocated for the thread's user- and kernel-mode stacks and for any other per-thread data.
I understand that as well, but what I did not expect to see was a memory creep up over several minutes then get release hours latter. I figured I would see an immediate increase in size right when the threads were created but not that I would ocntinue to see a creep up after that.
Thanks.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
so maybe my problem (couple threads up) is that .NET returns shared memory in use by a other processes. Does anyone know how to compute a proper amount of memory like taskmanager does?
|
|
|
|
|
|
Hi,
Can someone tell me the way by which the 'obj' directory created to store temporary files in the .NET framework Ex.
%Project Directory%\obj\<configuration>
Can be changed to some other path.
Since the output directories can be changed from the properties page of the project, but is there any similar way by which the 'obj' diretory path can be changed
Appreciate all the help
Saleem
|
|
|
|
|
was trying to do this.
1. Spawn cmd.exe and have a dialog with it sending commands to it and getting the output.
I did all the relevant things . All those properties and things , But I cant read the output , or I think the process exits itself. The code I am trying is given below.
2. I was trying to spawn bitsadmin.exe with the argument /list but got this error .
BITSADMIN version 2.0 [ 6.6.2600.2180 ]
BITS administration utility.
(C) Copyright 2000-2004 Microsoft Corp.
Unable to get console input mode - 0x80070006
The handle is invalid.
// This is the the code I am using to try it out.
private void button1_Click(object sender, EventArgs e)
{
Process p = new Process();
ProcessStartInfo pInfo = new ProcessStartInfo();
pInfo.RedirectStandardOutput = true;
pInfo.RedirectStandardError = true;
pInfo.RedirectStandardInput = true;
pInfo.FileName = "bitsadmin.exe";
pInfo.Arguments = "/list";
pInfo.CreateNoWindow = true;
pInfo.UseShellExecute = false;
p.StartInfo = pInfo;
p.EnableRaisingEvents = true;
p.OutputDataReceived += new DataReceivedEventHandler(process1_OutputDataReceived);
p.ErrorDataReceived += new DataReceivedEventHandler(process1_ErrorDataReceived);
p.Exited += new EventHandler(process1_Exited);
p.Start ();
//p.StandardInput.WriteLine("dir");
}
private void process1_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
this.Text = "process1_OutputDataReceived";
textBox1.Text += e.Data + "\n";
}
private void process1_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
this.Text = "process1_ErrorDataReceived";
textBox1.Text += e.Data + "\n";
}
private void process1_Exited(object sender, EventArgs e)
{
this.Text = "process1_Exited";
Process p = sender as Process;
textBox1.Text += p.StandardOutput.ReadToEnd() + "\n";
}
}
|
|
|
|
|
|
u did great job with the shell control , but unfortunately it did not work for me bcz I am using the same method to do things.
It turned out that the problem is with bitsadmin.
I spawned it from a console app and it did work fine.
Then I tried a workaround. I spawned a console app from my WinForms App and that Console App spawned Bitsadmin . But the Problem persists ... POOR ME
|
|
|
|
|
UGH! Why is this so hard?
It's not really hard, just annowuying that I have to do it.
All I want to do is copy one hashtable from here to there
dim firstHashtable as NewHashtable
dim secondHashtable as new Hashtable
firstHashtable.Add("Key1", "Value1")
firstHashtable.Add("key2", "Value2")
secondHashtable = firstHashtable
I don't want a shallow copy, or a shallow clone... no fancy shmancy pointer stuff.. all I want is is a second copy of the hashtable.
There is a Copy method, but noooooooooo, that copies the contents fo some funky array...
UGH!
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
If you just want a copy of the Hashtable, use the Clone method
<br />
secondHashtable = (Hashtable) firstHashtable.Clone();<br />
This will create a copy of the hashtable, but will *not* make a copy of the entries in the hashtable, they will be referring to the same object. If you want a copy of that too, try serializing and deserializing it to and from a MemoryStream. Something like
<br />
BinaryFormatter formatter = new BinaryFormatter();<br />
MemoryStream memoryStream = new MemoryStream();<br />
formatter.Serialize(memoryStream, firstHashtable);<br />
secondHashTable = (Hashtable) formatter.Deserialize(memoryStream);<br />
Regards
Senthil
My Blog
|
|
|
|
|
Hi,
I am trying to dynamically load assemblies from a Web Service but I am getting an exception telling me Access Denied. I'm not 100% on Trusting Assemblies and that is probably what is hurting me.
What do I need to do, to get the Web Service to call Activator.CreateInstance without this error?
Any help would be appreciated.
Cheers,
"If you're too careful, your whole life can become a f---in' grind." - Mike McD (Rounders)
|
|
|
|
|
i dont want to change my application to a console app because i dont want the console showing up whenever i run my application.
BUT..
i needed to have some commandline options to the application..
ex: my_app -e somefile.txt
i would now need to write to the console any error messages i would encouter.
is there a way to output to the console
like using Console.writeln("message"); when my application is a windows application?
thanks..
-- kaloy --
|
|
|
|
|
If you're not in a console application, and you're debugging, it'll forward to the debug output window. If you want to forward to some sort of stream (say a text file or network connection), you could use Console.SetOut. If you want the errors to display in a text box or something, the only method I've discovered so far is to make your own version of TextWriter that overrides the Write and WriteLine functions (there's a lot of them -- just do the ones you need), and Console.SetOut to that.
Actually, it might be interesting to make an article about this.
|
|
|
|
|
thanks..
but is there a way to display the messages on the same console that called the application?..
i dont need to forward it to other streams..
maybe i'll just have to save it to a file if i could NOT find a way to display it.
thanks anyway..
-- kaloy --
|
|
|
|
|
Sorry, I don't think I really understood what you're trying to do.
So you have a console application which calls a windowed application, and you want the Console.WriteLine calls from the windowed application to show up in the original console application?
|
|
|
|
|
sorry about the confusion..
i have a windows application. when i open the application from a command prompt (or a console). i need to display the error messages to the console.
the current behavior is no messages are displayed.
hope this clears things up
thanks for your time..
-- kaloy --
|
|
|
|
|
Compile this as a console program, call it "dump.exe" maybe.
<br />
using System;<br />
using System.IO;<br />
<br />
namespace Dump<br />
{<br />
class Class1<br />
{<br />
[STAThread]<br />
static void Main(string[] args)<br />
{<br />
char[] buffer = new char[512];<br />
int len;<br />
while((len = Console.In.Read(buffer, 0, 512)) != 0)<br />
Console.Write(buffer, 0, len);<br />
}<br />
}<br />
}<br />
<br />
When you call your program from the console, call it up like this: my_app -e somefile.txt | dump . This pipes the console output to dump.exe, which in turn displays it to the console.
Or, rather than using that dump program, you can use more like this: my_app -e somefile.txt | more . The problem with this, though, is that it stops and waits for you to hit a key once it fills up the buffer.
If you just want to dump the Console output to a file, you can say my_app.exe -e somefile.txt > consoleoutput.txt .
|
|
|
|
|
Has anyone seen the following error, using WSE 2.0 :
Microsoft.Web.Services2.Security.SecurityFault: An error was discovered processing the <security> header ---> System.ArguementOutOfRangeException: Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.
Then a call stack.
Attempting to use WSE 2.0 to login into my webservice using Kerberos Tokens. I only get this error when logging into the webservice if the webservice is on the local machine. If its on another machine, it seems to work ok.
Cheers,
"If you're too careful, your whole life can become a f---in' grind." - Mike McD (Rounders)
|
|
|
|
|
Hi,
Im beginner in direct3d programming.after I had installed directx 9.0 sdk,tried to write code using the methods of the IDirect3D9 interface. but IDE(Visual Studio 7)doesn't show list members by reference pointer to the interface .
please let me know how to ensure that.
Thanks
|
|
|
|
|
Hi, I had solved my problem.
Goto directoty \\Windows\Assembly\GAC then copy all file dll of Microsoft.DirectX into :\\Microsoft Visual Studio .NET 2003\Common7\IDE\PublicAssemblies
Thanks!
|
|
|
|