|
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++;
|
|
|
|
|
jblouir wrote: but im still stuck with trying to add an object to a global object array.
What is the problem? If fixed lenght of array is problem, use collection.
"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
|
|
|
|
|
jblouir wrote: im still stuck with trying to add an object to a global object array
You can't add objects to an array - They have a fixed length.
You may wish to try an ArrayList.
Also, global variables are rarely justified in an object oriented language. You may wish to have a rethink about your design.
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
|
|
|
|
|
Well I have a game loop in void Main, and I have a few methods, one being initialise which sits in the loop that repeats until input = exit.
the loop needs the input variable
and initialise needs the input variable
they need to be the same, and the best way I found of doing that is using a global variable.
I have been literally programming in C# for less than a week, I am doing things that work and learning as I go, if there is a better way to do it then I implement the new method.
I had thought that I could make a method that would return input but couldnt work it out at the time.
// Edit
And yes, the internet is my only resource at the moment, when I get the money to spend ill buy a book on C#.
|
|
|
|