|
Before you spend a lot of time, just perform a simple experiment:
- run the app, don't let it exit
- watch the working set on TaskManager
- minimize the main form
- restore the main form
- watch the working set again on TaskManager
if it got way down, then nothing is wrong; the memory IS available for use by other processes, and minimizing makes Windows reclaim memory from an app. The effect will be most noticeable on recent Windows versions (Vista, 7).
if not, you are holding on on something, or have a real leak.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Wouldn't it be better if he uses some kind of memory profiler? They would, IMO, give specific results.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
I haven't used memory profilers yet, I include what I deem necessary in my own code. So I can't advice about them as I don't know how intelligible their output would be for a novice.
And that is why I prefer a simple experiment over installing yet another tool.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
I haven't used a profiler as well. This morning I downloaded one to find the cause of my problem. The profiler however gives me loads and loads of information which I don't know how to 'read'. I tried your tip and yes, the amount of used memory dramaticly decreases when minimized. This is however when I use my test application which is a windows forms app. The actual app. is a Windows Service and since that has no GUI I cannot minimize it Thanks for the tip!
|
|
|
|
|
yes, "loads of information a novice won't understand" often is the outcome of a tool, even a good one.
your app (as a WinForms app) going down to acceptable and repeatable levels should tell you all is well.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
<br />
string from, to;<br />
from = frm.dtp1();<br />
to = frm.dtp2();<br />
sql = "select convert(varchar(10),tim,120) as dates,sum(mone) as totals,count(ID) as totalman from pat where (datepart(mm,tim) like '__' or datepart(mm,tim) like '_') and convert(varchar(10),tim,120) between '" + from + "' and '" + to + "' group by convert(varchar(10),tim,120)";
like that,i use this SQL do my report,then write Sum ({DataTable1.totalman}) and Sum ({DataTable1.totals}) on my crystal report.then run my project
the totalman should be 62,but it shows on report is 62.00,why?i think it should't like that?
|
|
|
|
|
Hi guyzz.. i have a doubt may be i have a query in C# coding and the query returns a string... Now i need to perform a check using if statement, my check is that if the query returns any string value then grant permission else access denied... Now my doubt is how do i specify "return any string value" in the if condition... plz advice...
If(query == ?????)
{
permission granted
}
|
|
|
|
|
Either check if (query.Length > 0) or if (query != string.Empty) . If your query variable can be null then you can check if(query != null) . Good luck!
<added>
so your statement should read:
if (query != null)
{
if (query.Length > 0)
}
|
|
|
|
|
Thanx.. its actually very silly doubt... the logic dint strike me as im a new comer in programming... Thanx alot..
regards,
tash
|
|
|
|
|
to check if a string is null or empty, usually if(!String.IsNullOrEmpty(value)) should be used. This checks for both empty and null strings.
|
|
|
|
|
Thanx buddy...
Regards,
Tash
|
|
|
|
|
welcome!!
|
|
|
|
|
How come is still don't remember this String method..?
|
|
|
|
|
Happens buddy!!! All in a day's work.
|
|
|
|
|
if (!string.IsNullOrEmpty(query))
{
}
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Hi Friends,
Is possible to run 500 threads per second using c#?
Please help me
Thanks in advance
|
|
|
|
|
C# would not be the limiting factor.
Windows could probably cope; a server version would for sure.
But I haven't encountered any application yet where it would make sense to have that many threads in a single process. It would be a huge waste of cycles (thread switches are expensive), bytes (each thread has its context, where the stack is the biggest chunck), and time (your cache efficiency goes down as the fixed size caches are used by more threads now).
Here is my rule of thumb in multi-threading: For most apps, it does not pay to have similar code in more than 1*N to 2*N threads where N is the number of processors.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Thank you your reply.
Is there any example to use multi threading (Asynchornous and thread pool) in C# window service application?
|
|
|
|
|
Does this[^] help?
Now...bring me that horizon. And really bad eggs...Drink up me hearties, YO HO!
|
|
|
|
|
|
Luc Pattyn wrote: have similar code in more than 1*N to 2*N threads
My rule of thumb is 1.5*N
Harvey Saayman - South Africa
Software Developer
.Net, C#, SQL
you.suck = (you.Occupation == jobTitles.Programmer && you.Passion != Programming)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
Harvey Saayman wrote: 1.5*N
you may run into trouble on an AMD triple core...
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
Even on single core dinosaurs...
I was thinking that same thing just after clicking post on my OP
Harvey Saayman - South Africa
Software Developer
.Net, C#, SQL
you.suck = (you.Occupation == jobTitles.Programmer && you.Passion != Programming)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
Having rules of thumb like 2* number of processors is a totally pointless affair.
Consider the following scenario
--I want to wait on 70 blocking operations
--When one of these operations complete. I would like a response/somethingto happen, quickly (Low latency)
I could
*Have 2*2 processors threads constantly polling all 70 blocking operations every millisecond to see when they are done. This would waste lots of CPU
*Use 70 threads which are all in Wait mode which would consume very little CPU
Using 70 threads would be far better in this case
The number of threads you need has nothing to do with the number of CPUs. And everything to do with latency and how much blocking operations you need to wait on
|
|
|
|
|
Theoretically, yes... you can have unlimited threads. But in practice, not so much
As Luc pointed out 500 threads are a bit heavy. If their running similar code I'd use Smart Thread Pool[^]
Its easy to use, quite flexible and to quote JSOP, "It simply works"
Harvey Saayman - South Africa
Software Developer
.Net, C#, SQL
you.suck = (you.Occupation == jobTitles.Programmer && you.Passion != Programming)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
How can I copy a multidimensional List ?
public class DSensingDataCollection
{
private string _DAreaID;
private string _DModel1;
private string _DModel2;
private string _DModel3;
private string _DDeviceID;
private string _DDeviceType;
private bool _DIsNow;
private int _DResult;
private int _DSeq;
private int _DSensorCount;
private List<DSensingData> _DSensingData;
public string DAreaID
{
get { return _DAreaID; }
set { _DAreaID = value; }
}
public string DModel1
{
get { return _DModel1; }
set { _DModel1 = value; }
}
public string DModel2
{
get { return _DModel2; }
set { _DModel2 = value; }
}
public string DModel3
{
get { return _DModel3; }
set { _DModel3 = value; }
}
public string DDeviceID
{
get { return _DDeviceID; }
set { _DDeviceID = value; }
}
public string DDeviceType
{
get { return _DDeviceType; }
set { _DDeviceType = value; }
}
public bool DIsNow
{
get { return _DIsNow; }
set { _DIsNow = value; }
}
public int DResult
{
get { return _DResult; }
set { _DResult = value; }
}
public int DSeq
{
get { return _DSeq; }
set { _DSeq = value; }
}
public int DSensorCount
{
get { return _DSensorCount; }
set { _DSensorCount = value; }
}
public List<DSensingData> DSensingData
{
get { return _DSensingData; }
set { _DSensingData = value; }
}
public DSensingDataCollection()
{
this.DAreaID = "";
this.DModel1 = "";
this.DModel2 = "";
this.DModel3 = "";
this.DDeviceID = "";
this.DDeviceType = "";
this.DIsNow = true;
this.DResult = 0;
this.DSeq = 0;
this.DSensorCount = 0;
this.DSensingData = new List<dsensingdata>();
}
}
public class DSensingData
{
private string _DSensorTypeID;
private string _DMinValue;
private string _DMaxValue;
private int _DSlot;
private float _DValue;
private float _DDelta;
public string DSensorTypeID
{
get { return _DSensorTypeID; }
set { _DSensorTypeID = value; }
}
public string DMinValue
{
get { return _DMinValue; }
set { _DMinValue = value; }
}
public string DMaxValue
{
get { return _DMaxValue; }
set { _DMaxValue = value; }
}
public int DSlot
{
get { return _DSlot; }
set { _DSlot = value; }
}
public float DValue
{
get { return _DValue; }
set { this._DValue = value; }
}
public float DDelta
{
get { return _DDelta; }
set { this._DDelta = value; }
}
public DSensingData()
{
this._DSensorTypeID = "";
this._DMinValue = "";
this._DMaxValue = "";
this._DSlot = 0;
this._DValue = 0;
this._DDelta = 0;
}
public DSensingData(string _DSensorTypeID, string _DMinValue, string _DMaxValue, int _DSlot, float _DValue, float _DDelta)
{
this._DSensorTypeID = _DSensorTypeID;
this._DMinValue = _DMinValue;
this._DMaxValue = _DMaxValue;
this._DSlot = _DSlot;
this._DValue = _DValue;
this._DDelta = _DDelta;
}
}
public class DDeviceData
{
private string _DeviceID;
private DBufferData _DBufferData;
public string DeviceID
{
get { return _DeviceID; }
set { _DeviceID = value; }
}
public DBufferData DBufferData
{
get { return _DBufferData; }
set { _DBufferData = value; }
}
public DDeviceData()
{
this._DeviceID = "";
this._DBufferData = new DBufferData();
}
public DDeviceData(string param)
{
this._DBufferData = new DBufferData();
if (uHeader.gDevice.ContainsKey(param) == false)
{
this._DBufferData = new DBufferData();
uHeader.gDevice.Add(param, this._DBufferData);
}
else
{
IDictionaryEnumerator items = uHeader.gDevice.GetEnumerator();
while (items.MoveNext())
{
if (items.Key.ToString().Equals(param))
{
this._DBufferData = (DBufferData)items.Value;
}
}
this.DBufferData.DSensingDataCol3.Clear();
-- First and second array to array
this.DBufferData.DSensingDataCol2.Clear();
-- 0 the first array to array
this._DBufferData.DSensingDataCol1.Clear();
}
DSensingDataCollection input1 = new DSensingDataCollection();
input1.DAreaID = "1234";
input1.DDeviceID = "1234";
input1.DDeviceType = "edv";
input1.DIsNow = true;
input1.DModel1 = "fm001";
input1.DModel2 = "fm002";
input1.DModel3 = "fm003";
input1.DResult = 0;
input1.DSensorCount = 8;
input1.DSeq = 3;
input1.DSensingData.AddRange(new DSensingData[]{
new DSensingData("edv","34.1", "45.1", 0, 12.9f, 10.8f)});
this.DBufferData.DSensingDataCol1.Add(input1);
DSensingDataCollection input2 = new DSensingDataCollection();
input2.DAreaID = "2234";
input2.DDeviceID = "2234";
input2.DDeviceType = "edv";
input2.DIsNow = true;
input2.DModel1 = "fm001";
input2.DModel2 = "fm002";
input2.DModel3 = "fm003";
input2.DResult = 0;
input2.DSensorCount = 8;
input2.DSeq = 3;
input2.DSensingData.AddRange(new DSensingData[]{
new DSensingData("edv","11.1", "12.1", 0, 3.5f, 4.2f)});
this.DBufferData.DSensingDataCol1.Add(input2);
}
}
public class DBufferData
{
private List<DSensingDataCollection> _DSensingDataCol1;
private List<DSensingDataCollection> _DSensingDataCol2;
private List<DSensingDataCollection> _DSensingDataCol3;
public List<DSensingDataCollection> DSensingDataCol1
{
get { return _DSensingDataCol1; }
set { _DSensingDataCol1 = value; }
}
public List<DSensingDataCollection> DSensingDataCol2
{
get { return _DSensingDataCol2; }
set { _DSensingDataCol2 = value; }
}
public List<DSensingDataCollection> DSensingDataCol3
{
get { return _DSensingDataCol3; }
set { _DSensingDataCol3 = value; }
}
public DBufferData()
{
this._DSensingDataCol1 = new List<DSensingDataCollection>();
this._DSensingDataCol2 = new List<DSensingDataCollection>();
this._DSensingDataCol3 = new List<DSensingDataCollection>();
}
}
class Program
{
static void Main(string[] args)
{
string deviceid = "53410101";
DDeviceData ar = new DDeviceData(deviceid);
DDeviceData br = new DDeviceData(deviceid);
}
}
|
|
|
|