|
Whoops! My mistake. I misread your using line and though it wsa for a different object. using will call the .Dispose() method for you.
You've got to have another object that you're not disposing, like a Bitmap maybe?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Based on these conversations, I've tried a few other things. Inside FrmMasterParts, I've stepped through the creation of it and each UserControl I create inside of it. Each item I've created, I ensure there is a Dispose() or a null set to it in the Dispose() method (The enums and such didn't like that so I took them back out!). Literally, if it wasn't a form component, I added it to the Dispose(). I did this for the form and each UC.
When executing the program, upon the second and successive instantiation of FrmMasterParts, it's entire content (with the exception of the components) has everything set to undefined (as expected). This would validate that a clean copy of the form is being created with the using() . Upon display of the form, the additional memory is added. Upon the last brace of the using() , FrmMasterParts is no longer accessible but the memory has not been release. Execute GC.Collect(). Still no luck.
The last time I used a memory tool was the early '90's. Do you know of one that I can try to look at the physical memory to get an idea of what is being left out there?
An interesting note: When I minimize my 100MB program, task manager drops by about 99MB. Maximize again. I can do all kinds of stuff and memory stays small. Click the button to open this form, almost all 99MB comes back. Evaluate the content of FrmMasterParts in Autos, and it is empty as discussed above.
This is going on on my Dell laptop, a Compaq laptop as well as the development workstation and production servers so it isn't hardware related.
Thanks for your time.
|
|
|
|
|
OK. First, setting something to null isn't necessary. Once the object can't be reached any more, the GC will get around to collecting it.
What do you have that's allocating that much stuff?!
The problem you're running into is that you have unmanaged (not under the .NET memory manager control) resources being consumed and not released by one, or more, of your components on that form. There's a component that isn't releasing unmanaged memory and/or other resources, such as handles.
Oh! Task Manager is probably the worst tool you could use to track the memory usage of a managed application. Use the Performance Monitor with the .NET Framework counters or something like the CLR Profiler[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 20:30 Wednesday 28th September, 2005
|
|
|
|
|
Setting didn't seem to be worth anything to me but one of my contractors insisted it was necessary. Every time he does an object.Dispose() , the next line is object = null .
The allocation of data is pulling information from the database and displaying it on screen. The screen does allow maintenance so there are several drop-down boxes on the form as well as the order data itself. I've never understood the 3MB from the beginning since it only seems like a few K of data.
To my knowledge, the only way to use unmanaged memory/code is to explicitly code it and block it into an unmanaged code block. I don't do that anywhere. If there is a way to use unmanaged memory inadvertantly, let me know what the key words are that I need to be looking for and I can focus on those.
I've downloaded CLR Profiler to see what is going on. The reason I use the Task Manager is because the boxes I'm using the application on are Citrix boxes with 4GB of memory. I have about 35 users on the system and at 9:00 I'll be sitting with about 1.5GB in use and the box is happy. As it gets to 4GB and 5GB (in the task manager), that's when things start getting flakey. So I was using that as my guide as to how the box is performing. I can look at the individual processes and those people that are 150MB to 300MB, I have them log out and log back in, memory drops back down to 2-3GB and everyone is happy again for a while.
I do thank you very much for your time.
|
|
|
|
|
dbetting wrote:
Setting didn't seem to be worth anything to me but one of my contractors insisted it was necessary. Every time he does an object.Dispose(), the next line is object = null.
How much are you paying him? No, it's not necessary.
Objects that go out of scope, or can't be reached on any code path, are killed, or nulled if you wish, automatically by the Garbage Collector.
dbetting wrote:
To my knowledge, the only way to use unmanaged memory/code is to explicitly code it and block it into an unmanaged code block. I don't do that anywhere. If there is a way to use unmanaged memory inadvertantly, let me know what the key words are that I need to be looking for and I can focus on those.
There are no keyword to be looking for. The .NET Framework is essentially a large collection of classes that wraps a good deal the Win32 API. For instance, the Windows.Form class wraps a Win32 Window, which has an unmanaged window handle behind it. Calling .Dispose() on your .NET Framework Form object releases that unmanaged handle.
You're using unmanaged resources whether you explicitly do so yourself or not. An easy way to do release them is to make sure you call .Dispose() on any objects that expose this method, when your done with them.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
dbetting wrote:
An interesting note: When I minimize my 100MB program, task manager drops by about 99MB. Maximize again. I can do all kinds of stuff and memory stays small. Click the button to open this form, almost all 99MB comes back. Evaluate the content of FrmMasterParts in Autos, and it is empty as discussed above.
This is working as designed. When the GC runs is marks memory as free in it's internal mananger, and will be reused when additional objects are allocated. It is not returned to the OS immediately because there's a major performance hit from teh context switching involved. The memory will be returned if windows is getting low and asks for more, or if the program is 'made inactive' (can't think of the appropriate phrase here). Minimization will do this.
|
|
|
|
|
How can I easy copy a Row from on DataView to another DataView?
Something like:
<br />
<br />
dvUnsortedList = GetDataFromSomeWhere()<br />
DataTable dtSorted = new DataTable("dtSortedList");<br />
dtSorted = dvUnsortedList.Table.Clone();<br />
dvSortedList = new DataView(dtSorted);<br />
.<br />
.<br />
.<br />
if((int)dvUnsortedList[i].Row["lngOwner"] == 0)<br />
{<br />
dvSortedList.Table.Rows.Add(dvUnsortedList[i].Row); <br />
<br />
Thanks
Thomas
-- modified at 8:40 Wednesday 28th September, 2005
|
|
|
|
|
Table.Rows.Add does not copy a row it assigns a row to a table and as you have seen a row can only belong to one table at a time. If you want to copy a row you could use:
<br />
dvSortedList.Table.Rows.Add(dvUnsortedList[i].Row.ItemArray)<br />
Which does make a copy of the data in the row.
|
|
|
|
|
i would like to know the best obfuscator or the most used one.
i need an obfuscator to make harder the job for people who wants to use reverse engineering to read my code.
Thanks
|
|
|
|
|
|
Yes, i agree with you, but i need an answer about the best one. so i posted it again.
tks
|
|
|
|
|
Hi folks,
I am stuck with a problem. I need to read a config file of a windows service. Can any body guide me or give some pointer for this.
thanks in advance.
Rajeev
|
|
|
|
|
Hi all,
I have to do some web scraping from a client's web site as they can't give me a direct feed of data (for various reasons too long and borign to explain here!) so I thought I'd use the WebRequest class which I've used before with success.
However, the data I'm scraping is on pages linked 1 or 2 levels down and they require cookies which WebRequest doesn't seem to handle natively. I added a CookieCollection object to my code but when I call my FetchHTML method (below) for a lower level page (ie: linked from the top page) I just get back HTML containing a message saying that cookies have to be turned on. I think I basically just don't really understand what I'm meant to do with the CookiesColelction between requests so if anyone can look at my method below and tell me where I'm mesing up it would be deeply appreciated!
To recap - it loads the first level page in but any successive pages I get HTML back containing the "cookies are not turned on" message rather than the page I want.
Any help would be great!!
Mike
private string FetchHTMLPage(string strURL)
{
//Create a new UTF8 encoding object
System.Text.UTF8Encoding objUTF8 = new System.Text.UTF8Encoding();
request = (HttpWebRequest)WebRequest.Create(strURL);
request.CookieContainer = new CookieContainer();
response = (HttpWebResponse) request.GetResponse();
response.Cookies = request.CookieContainer.GetCookies(request.RequestUri);
Stream resp = response.GetResponseStream();
System.Text.Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
// Pipe the stream to a stream reader with the required encoding format.
StreamReader sr = new StreamReader( resp , encode );
strHTML = sr.ReadToEnd();
return strHTML;
}
|
|
|
|
|
You have to handle the cookies the same way a browser would. You get cookies in a response, you have to keep them and send them back to the server in the requests.
---
b { font-weight: normal; }
|
|
|
|
|
Well, thanks, but I sorta knew that... that's exactly what I can't get to work so a little more explanation is what I'm looking for.
I've hunted high and low for a working example of this with no luck... if anyone has got this working I'd sure appreciate a glimpse at some working code just to see what I'm missing or have screwed up!
Mike
|
|
|
|
|
Have you tried to take the cookies collection you get in the response, and just put that in the requests that you send?
You might have to keep a cookie collection, and for each response update it with the new cookies you might get.
---
b { font-weight: normal; }
|
|
|
|
|
Hi all,
Does anybody know how to remove the border from around the PropertyGrid control? I've tried overriding OnPaint and doing custom drawing but can't seem to get anything to work...
Any ideas would be appreciated
rob
|
|
|
|
|
I am writing a simple tool that extracts data from an xls and uses it to write an XML file using the XmlTextWriter class. I have a test harness written, problem is I keep getting the following error:
"VS cannot debugging the target as the <projectPath>....exe is missing. Please build the project and retry, or set the OutputPath and AssemblyName properties appropriately to point at the correct location for the target assembly."
I have added the reference "Excel 11.0" so that isn't the problem. I am using a file dialog and have added the "System.Windows.Forms" reference so there is no problem there.
Has anyone ever had this problem beofre when dealing with Excel or XmlTextWriter?
|
|
|
|
|
I've had the same problem before when VSS gets its hands on the executable for the application. I normally end up deleting the contents of ProjectName\Debug\bin and then rebuild the project, seems to sort things out.
On a different note, are you referencing Excel directly or using the Primary Interops (PIA) from Microsoft? I've found c# doesn't like a lot of the methods in Excel if referenced directly, but i don't think it's causing this problem.
HTH
Russ
|
|
|
|
|
I've had the same problem before when VSS gets its hands on the executable for the application. I normally end up deleting the contents of ProjectName\Debug\bin and then rebuild the project, seems to sort things out.
On a different note, are you referencing Excel directly or using the Primary Interops (PIA) from Microsoft? I've found c# doesn't like a lot of the methods in Excel if referenced directly, but i don't think it's causing this problem.
HTH
Russ
|
|
|
|
|
I have the ListBox and UserControl on my form, the problem is: how to scroll ListBox when the UserControl is focused and user rolls the mouse wheel. It seems that the easiest way is to send the message to ListBox that weel was rolled, but how to this. Or maybe there is another way to solve this problem?
|
|
|
|
|
in a project i used richtextbox, i saved richtextbox, but i cannot see images on rrf file. I tried all possibilities.
RichTextBox1.SaveFile("", RichTextBoxStreamType.PlainText)<br />
RichTextBox1.SaveFile("", RichTextBoxStreamType.RichNoOleObjs)<br />
RichTextBox1.SaveFile("", RichTextBoxStreamType.RichText)<br />
RichTextBox1.SaveFile("", RichTextBoxStreamType.TextTextOleObjs)<br />
RichTextBox1.SaveFile("", RichTextBoxStreamType.UnicodePlainText)
I think 4th is true way, but it doesnt working.
And another question, I have to do something to this file so that Word pad cannot open this file, how could i do this. I intend to this file only can be opened by my program.
|
|
|
|
|
Greeky wrote:
I have to do something to this file so that Word pad cannot open this file
If you do that, you're program isn't going to be able to open it either. Since you're using the RichTextBox's methods to load and save files, anything you do to the file to stop WordPad, which is a glorified RichTextBox itself, will stop you from loading the file too.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
The shape have a line and a empty triangle that joined the end of the line.
Can you give me some code?Thanks!
|
|
|
|
|
I think you want this:
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
GraphicsPath capPath = new GraphicsPath();
Point[] cappoints = new Point[] { new Point(0, 10), new Point(-10, 0), new Point(10, 0), new Point(0, 10) };
capPath.AddLines(cappoints);
CustomLineCap myCap = new CustomLineCap(null, capPath);
Pen capPen = new Pen(Brushes.Black, 1);
capPen.CustomEndCap = myCap;
capPen.CustomStartCap = myCap;
myCap.StrokeJoin = LineJoin.Round;
myCap.WidthScale = 2;
e.Graphics.DrawLine(capPen, new Point(100, 100), new Point(300, 100));
Christian Graus - Microsoft MVP - C++
|
|
|
|