|
|
The framework :
=============
C# .Net1.1, under visual studio 2003
We are developped a client-server using System.Runtime.Remoting functionnalities.
At "new loading" message receiption, we launch a thread to handle the new loading.
becaus of memory problems server(console application),
we added to regular intervals a call to
SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1) ;
and all our objects implement a Dispose class with SuppressFinalize call.
GC.SuppressFinalize(this);
It seems to work, when you look at the process manager, the used memory % stays betwenn 7 and 10Mo...
The Problem
===========
we need to add a new capability to our server, and we detect the following problem :
on Thread.Start we catch "OutOfMemory" exception. and our server is blocked
With a simulation program which sends messages to the server and write all 5 minutes the server process state, here this is that we obtain :
07/06/2007 10:14:38 NbThreads=15 VMem=138 428 416
UserProcTime=00:00:00.3593750 TotalProcTime=00:00:00.9375000
PrivateMem=17203200
07/06/2007 10:19:38 NbThreads=22 VMem=442 904 576
UserProcTime=00:00:02.7343750 TotalProcTime=00:00:06.7812500
PrivateMem=30269440
07/06/2007 10:24:38 NbThreads=21 VMem=715 534 336
UserProcTime=00:00:04.3906250 TotalProcTime=00:00:11.7812500
PrivateMem=37363712
07/06/2007 10:29:38 NbThreads=22 VMem=1 002 844 160
UserProcTime=00:00:06.2031250 TotalProcTime=00:00:17.3593750
PrivateMem=44703744
and it grows up until VMem is equal to 2 000 000 000 and we got outofmemory exception.
(Vmem = Process.VirtualMemorySize, UserProcTime = Process.UserProcessorTime, TotalProcTime = Process.TotalProcessorTime
et PrivateMem =Process.PrivateMemorySize
As our server is a console application with threads and because Microsoft (support.microsoft.com : article 828988) recommands the multithreading using
I try to use :
[MTAThread]
static void Main
But, it doens't help...
My Question
==============
Is anyone can explain me where is my problem and how can i resolve it?
|
|
|
|
|
Maybe with more details someone will help me
After using MemProfier and CLR tools I've seen that :
Virtaul memory seems allocated in dataBase.open call :
To give an idea of my code :
using System.Data.Odbc;
OdbcConnection oConn = new OdbcConnection(...);
OdbcCommand oCmd = MyFunctiontoCreateCmd(..);
oConn.Open();
... oCmd.Execute(); ...
oConn.Close();
oConn.dispose();
oConn = null;
I use Firebird 1.5.3.4870, OdbcDriver 1.2.0.69
I don't understand if my problems come from C# dll or firebird ones.
MemProfiler tells me that UnsafeNativeMethods.Odbc32.SQLDriverConnectW calls unmaned code...
(To follow...)
|
|
|
|
|
I made another test : only odbcconnection creation.
Open, then Close...
but also memory leak !
pb C# (odbc) or firebird driver ?
Here's my code :
public void DirectLoopNoThread()<br />
{<br />
Process aProcess = null;<br />
int i = 0;<br />
<br />
while (m_bNotStop)<br />
{<br />
OdbcConnection oConn = new OdbcConnection("DSN=CHGT_SECAB");<br />
oConn.Open();<br />
oConn.Close();<br />
oConn.Dispose();<br />
oConn = null;<br />
System.Threading.Thread.Sleep(1000);<br />
i++;<br />
if (i == 50)<br />
{<br />
i=0;<br />
aProcess = Process.GetCurrentProcess();<br />
Trace.WriteLine(DateTime.Now.ToString() + " TestDb :" <br />
+ " VMem=" + aProcess.VirtualMemorySize<br />
+ " PrivateMem=" + aProcess.PrivateMemorySize);<br />
aProcess.Dispose();<br />
aProcess = null;<br />
GC.Collect();
aProcess = Process.GetCurrentProcess();<br />
Trace.WriteLine(DateTime.Now.ToString() + " TestDb : GC.Collect"); <br />
Trace.WriteLine(DateTime.Now.ToString() + " TestDb :" <br />
+ " VMem=" + aProcess.VirtualMemorySize<br />
+ " PrivateMem=" + aProcess.PrivateMemorySize);<br />
aProcess.Dispose();<br />
aProcess = null;<br />
SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1) ;<br />
aProcess = Process.GetCurrentProcess();<br />
Trace.WriteLine(DateTime.Now.ToString() + " TestDb : GC.SetProcessWorkingSetSize"); <br />
Trace.WriteLine(DateTime.Now.ToString() + " TestDb :" <br />
+ " VMem=" + aProcess.VirtualMemorySize<br />
+ " PrivateMem=" + aProcess.PrivateMemorySize);<br />
aProcess.Dispose();<br />
aProcess = null;<br />
}<br />
}<br />
}
This is the obtained traces :
====================
18/06/2007 09:48:50 TestDb : DirectLoopNoThread
18/06/2007 09:49:41 TestDb : VMem=179871744 PrivateMem=12541952
18/06/2007 09:49:43 TestDb : GC.Collect
18/06/2007 09:49:43 TestDb : VMem=179871744 PrivateMem=12673024
18/06/2007 09:49:43 TestDb : GC.SetProcessWorkingSetSize
18/06/2007 09:49:43 TestDb : VMem=179871744 PrivateMem=12673024
18/06/2007 09:51:26 TestDb : VMem=288923648 PrivateMem=15372288
18/06/2007 09:51:26 TestDb : GC.Collect
18/06/2007 09:51:26 TestDb : VMem=288923648 PrivateMem=15372288
18/06/2007 09:51:26 TestDb : GC.SetProcessWorkingSetSize
18/06/2007 09:51:26 TestDb : VMem=288923648 PrivateMem=15372288
|
|
|
|
|
I want to know the length of string in pixels in a web based applicaiton. can anyone tell me how can i get it..?
If my mind can conceive it, and my heart can believe it, I know I can achieve it.
|
|
|
|
|
Please don't cross post.
In a web app, you really can't as you have no way of dealing with the font settings on the browsers your users have set. But, if you set absolute font sizes, you can use Graphics.MeasureString on the server, and assume they will be the same size on the client. It's definately better form to use relative sizes ( which means you can't do that )
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I am setting the font size on the server only but still I cannot use Graphics.MeasureString since it requires PaintEventArgs which cannot be used in Web projects. If it can still be used do u have any sample code to get the length in pixels which u can pls post it here.
If my mind can conceive it, and my heart can believe it, I know I can achieve it.
|
|
|
|
|
jain.ashish21 wrote: l I cannot use Graphics.MeasureString since it requires PaintEventArgs
No it does not. Try Graphics.FromImage().
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
I have a dropdown list box which has 4 ListItems in it . I want that when a user selects any item from dropdown list its index value should go in database table .
Suppose DropDownList has 4 values such as a, b , c , d . If user selects any of the value in dropdown list then the database should have value as 1 for a , 2 for b and so on ....
Thanks in Advance
|
|
|
|
|
Sneha,
You can use SelectedValue property for this.
For display puropse, you should use SelectedItem and when you are dealing with database, update it with SelectedValue.
Success!!!
|
|
|
|
|
Sneha,
You can use SelectedValue property for this.
For display puropse, you should use SelectedItem and when you are dealing with database, update it with SelectedValue.
Success!!!
|
|
|
|
|
I m still not getting it can u show me hint code .
|
|
|
|
|
Is it possible to evaluate a string as a method name?
Something like this:
string methodName = "Login";
invoke(methodName())
Anyone have any ideas?
- Projjal
|
|
|
|
|
See the documentation for the System.Reflection namespace. And also for the class Type .
Use the Type to find the MethodInfo and call Invoke on the MethodInfo object.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
* Reading: Developer Day 5
Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton
My website
|
|
|
|
|
Yes, you can do this with Reflection. For a start, http://www.google.com/search?q=methodinfo.invoke[^]
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Hi!
I'm looking for an example on how to program file access on remote computers.
I know the path (share), filename, the username and password on the remote computer, but I don't know how to program the access control.
I saw a post in another forum on the internet where someone suggested to use the NET USE command. To me, that doesn't look like the ultimate solution. I read somewhere about Generic prinipals? But there are no examples whatsoever on how to do it?!
Does anyone have any experience with that?
Regards Mats
|
|
|
|
|
net use G: \\host\path password /user:username
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_use.mspx?mfr=true
or
In an explorer window, click Tools and Map Network Drive. You can then put in the details there.
|
|
|
|
|
I think that this is not the way to do it.
I need code examples (C#) on how to access files on a remote computer. Not just to map a network drive. There must be another "cleaner" method to do this. Or am I completely wrong here?
|
|
|
|
|
In a previous post I was informed that I could count the number of elements in an array using.
// elements is a previously declared array
elements.Count
however .Count isnt available
I looked it up in the object viewer and it looks like its a part of the system namespace which I have included in my code.
Anyone know why it might not be showing up?
and also if
elements.Count
and
elements.Length
return the same value?
|
|
|
|
|
How can a property be part of the System namespace? Elements.Count won't ever return anything, so do yourself a favour and use the property that does exist, elements.Length
|
|
|
|
|
Forgive me if I am wrong but dont all the different classes such as array and int etc come from namespaces? Then .Count is derived from array which is part of system, ok so its a property, but if you dont have proper namespace it wont be there.
|
|
|
|
|
Count is a property, it isn't found in a namespace but on a class, and the class will be found in a namespace.
|
|
|
|
|
It is an array then use Length . If it any other type of collection then use Count .
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
* Reading: Developer Day 5
Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton
My website
|
|
|
|
|
Colin Angus Mackay wrote: It is an array then use Length. If it any other type of collection then use Count
Kinda sucks there is this "inconsistency". Yes, sure, logicaly array has lenght not count and collection doesn't have lenght but count, but... What about NumberOfElements or something for both.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Well I was unstructed to use this...
string [] elements = line.split(new char [] { ',' } );
if (elements.Count > 0)
{
int n;
elements is an array, when .Count didnt work I assumed it was because I missing a using namespace
.Length appears to work but im still stuck with trying to add an object to a global object array.
intIndex, strRoom,strDesc,strLook, i are all variables, descriptor being the object name
RoomData descriptor = new RoomData(intIndex, strRoom, strDesc, strLook);
GlobalVars.arrRoomData.SetValue(descriptor,i)
i++;
|
|
|
|