Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
C

coleydog

@coleydog
About
Posts
17
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Change Directory type info
    C coleydog

    This seems so silly, but, I've been googling now for 2 hours and can't find an answer. Hope someone here can help. I create a temp directory on the path Environment.SpecialFolder.LocalApplicationData combined with a session guid. No problem - the directory is created. The problem is that the 'Use folder type as a template:' (Explorer directory-properties-customize) is set by default on the create to 'Pictures and Videos' or 'Music' and I was wanting it to be set to 'All items'. (The folder look is incorrect on Process (verb 'open') explorer load.) Any help for the call to change the folder type would be greatly appreciated. (I'm running on Vista with VS2005). Thanks.

    .NET (Core and Framework) help workspace

  • Drag/Drop strange behaviour on Vista.
    C coleydog

    Hi all, I'm running with VS2005 Pro on Vista business. I've been attempting to get Drag/Drop working for files from emails, explorer etc. I have a problem that if I start Visual Studio (either as Admin or not) and load the project from VS then the DragEnter / DragDrop events never fire. However if I load the project by double clicking the .sln file from windows explorer the events fire and all works well. This behaviour is true for both my project and two sample projects I've downloaded from here... Strange.

    Visual Studio visual-studio csharp business help

  • XmlTextReader - try again
    C coleydog

    Thanks, That's exactly the property I was looking for. Cheers. :)

    .NET (Core and Framework) xml help tutorial

  • XmlTextReader - Child elements.
    C coleydog

    Thanks for that. That's what I've now done. Works fine. I just thought there would have to be some sort of 'HasEndElement' type property for an Element node on the XmlTextReader.Read Element. Cheers. :)

    .NET (Core and Framework) xml help tutorial

  • XmlTextReader - try again
    C coleydog

    Hi All, My last message post dropped the Xml lines so I'll substitute round brackets. I am reading Xml data using XmlTextReader on a file stream. I read the elements and the element attributes with no problem but I can't figure out how to identify if the current element has further child elements or is finalized (ends with />. I can handle (MyElement Name="MyName" Value="MyValue")(/MyElement) (the reader.Read() shows 'Element' (with 2 attributes) then EndElement - no problem) I have problems with (MyElement Name="MyName" Value="MyValue" /) (the reader.Read() shows 'Element' (with 2 attributes) then the next element) In the second case I can't figure out if the next element is a child element or not. Or to be more precise I don't know when the original element ends. Thanks.

    .NET (Core and Framework) xml help tutorial

  • XmlTextReader - Child elements.
    C coleydog

    Hi All, I am reading Xml data using XmlTextReader on a file stream. I read the elements and the element attributes with no problem but I can't figure out how to identify if the current element has further child elements or is finalized (ends with />). I can handle (the reader.Read() shows 'Element' (with 2 attributes) then EndElement - no problem) I have problems with ; (the reader.Read() shows 'Element' (with 2 attributes) then the next element) In the second case I can't figure out if the next element is a child element or not. Or to be more precise I don't know when the original element ends. Thanks.

    .NET (Core and Framework) xml help tutorial

  • Man spends Christmas Eve in Septic Tank
    C coleydog

    Perhaps he was attempting to commit sewer side...

    The Lounge com question

  • Change application description at run-time
    C coleydog

    Hello all, I'm sure this must be straight forward, I am just don't know where to look. I've tried googl'ing but can't figure out a precise search criteria to hone in on what I need. I've looked in the Application class and the Environment class to no avail. What I wish to do is change the application description (as appears in the description column of task manager) to reflect the particular action that the application is performing. I now it's possible because internet explorer does exactly that with web pages. Pointing me to the appropriate class or P/Invoke API call would be most appreciated. Thanks in advance, David.

    Visual Studio json workspace

  • LINQ and the future of database design/programming
    C coleydog

    Marc Clifton wrote:

    I'm beginning to sound like a broken record, but:

    No, you are exactly on the mark, and your points are exactly right. I make it a practice of building database table schema info into a 'metadata' table when a database is changed (using oledb or sql client to retrieve the table info) then I use this table in the app (now accessible also by odbc) to generate sql statements and data relationships. The result is if the database changes then the app framework (mostly) automatically adapts to the changes without app rebuilding. I always use Select * ... and design the tables to make this relatively efficient. Again if tables change the Select * ... automatically adapts. I use view tables to define columns and properties for grids etc so grid views can change without app change. For simplicity I use a codes database for all manner of code translations, things like transaction types, freight charges, branch codes, etc. I have a single maintenance user control which automatically builds on the fly the appropriate text boxes, combo boxes, check boxes required for the particular codes table maintenance, and automatically on the fly manages data create, modify and update and generates all appropriate sql statements. The approach seems to be in the opposite direction to MS and especially DLinq where code represents more and more specific instances of data and relies heavily on the structure of the underlying database. I was taught that OO best practice was to make code less reliant on the external environment not more reliant. I think that DLinq will create a great future for maintenance programmers.

    The Lounge csharp database linq design question

  • Garbage Collection & Memory Leaks.
    C coleydog

    Thanks for your help. I believe I've sorted the problem. If I minimize and maximize the main mdi form the Task Manager reports a low resized memory. So the GC really only works when it needs too and if there is no memory pressure it just lets the app grow. Thanks.

    C# visual-studio debugging performance tutorial question

  • Garbage Collection & Memory Leaks.
    C coleydog

    I think maybe your right. If I minimize the main mdi container form then maximize the task manager shows memory allocation has been reset to the expected minimum value. I guess the GC is saying its cheaper to do a full tidy up on minimize than save the untidied bloat to cache. Thanks.

    C# visual-studio debugging performance tutorial question

  • Garbage Collection & Memory Leaks.
    C coleydog

    OK so forms created with the VS designer have fields added to the form class to hold the instance creations of each of the controls added through the designer. Any events added during the designer phase are still active at the form Dispose stage. So there is a circular reference between the control event delegate ( textBox1.SomeEvent += new EventHandler(this.SomeMethod); ) and control create instance field ( TextBox textBox1; & this.textBox1 = new TextBox(); ) which prevails after the Dispose method is completed. So I will at least need to add to the Dispose method textBox1.SomeEvent -= new EventHandler(this.SomeMethod); etc.

    C# visual-studio debugging performance tutorial question

  • Garbage Collection & Memory Leaks.
    C coleydog

    Hi Christian, Could you please have a look at my reply to CaiX message. No I am not using ZX81, however the client is using Citrix with some 150 user base so memory usage does impact server utilisation. Also, how a form is shown does impact. ShowDialog() does GC the form. (and only the internal Finalize() method calls Dispose as Dispose(false) whereas Show() automatically calls Dispose(true) on Close and never GC's the form.

    C# visual-studio debugging performance tutorial question

  • Garbage Collection & Memory Leaks.
    C coleydog

    No, what I'm saying is this - private void DoSomething() { (new Form2()).Show(); } When Form2 is Closed (user action) Dispose(true) is automatically called by the CLR. All fine. But after calls to GC.Collect() or GC.GetTotalMemory(true) (both of which should force GC) the form (plus all the controls for the form are never GC'd) However, private void DoSomething() { (new Form2()).ShowDialog(); } When Form2 is Closed (user action) Dispose(true) is NOT automatically called by the CLR and shortly after, typically when further memory allocations are required the form gets CG'd. My point is then that (new Form2()).Show(); requires that a reference to the form be promoted somewhere within the CLR (or O/S) to keep track of the form as the DoSomething() method completes immediately. The internal reference to the form is never removed, even when the form is closed (only when the app terminates) so the form (and all of the form's controls) can never be GC'd. The typical base managed heap allocation for a complex form instance (multiple pages, multiple controls) appears to be around 1 to 2 megabytes (not including data) which remains after the form is Disposed. The application (an Mdi ERP solution) has around 500 forms and has a user base of around 150 users within the client organisation. The client decision to distribute the solution through Citrix is directly impacted by the cumulative effect of additional memory usage over 20 to 30 users on a typical Citrix server box. So if no way can be found to force the CLR (or O/S) to relinquish the reference to the form after it is closed and therefore eventually be GC'd then the client decision to distribute the solution through Citrix will need to be seriously re-evaluated. (Not the case for ShowDialog() which does not terminate the DoSomething() method until the form is Closed()) (therefore no promotion is necessary)

    C# visual-studio debugging performance tutorial question

  • Garbage Collection & Memory Leaks.
    C coleydog

    I have added a menu item to my Mdi container form which calls GC.GetTotalMemory( true ); and I report the returned value. GC.GetTotalMemory( true ) should force GC and the destructor (Finalize) as appropriate. This happens for all other class instances EXCEPT Forms displayed with the Show() method. (Modal Forms displayed with the ShowDialog method are GC'ed.)

    C# visual-studio debugging performance tutorial question

  • Garbage Collection & Memory Leaks.
    C coleydog

    I am using the Task Manager and it shows that each iteration of a new large form grows the exe memory usage by around 3MB (grows by 20MB during form execution, drops by around 17MB when the form is closed and GC.GetTotalMemory( true ) is called). After opening, running and closing just a few series of forms the app memory usage grows from 30MB to over 60MB, User Objects grows from 60 odd to over 130 and GDI objects grows from 80 plus to over 400. GC.GetTotalMemory( true ) returns around 7MB (Probably close to the correct value for chached data). I see that all class objects I create in the application are GC'ed except the forms and in the forms Dispose method I Close all appropriate objects and set all appropriate references to null. My client requires that the application be run under Citrix and the application is expected to remain open on the user desktop for the whole day. That means that over the course of the day the application could grow by several hundred megabytes multiplied by the number of Citrix clients on the server to me adds up to a disaster.

    C# visual-studio debugging performance tutorial question

  • Garbage Collection & Memory Leaks.
    C coleydog

    Hi all, For the last several days I've been trying to figure out why my windows mdi forms application doesn't tidy up resources correctly and continues to grow through multiple iterations of the same processes - ie Leaks Memory. To that end I created a small (single form) test Windows Application (TestGC). The TestGC form has 3 buttons (buttonShow, buttonShowDialog, buttonCollect) and a text box (textBoxMemory). The TestGC app was created as a standard vanilla app using VS (VS2005). I added the following line to the form Dispose method System.Diagnostics.Debug.WriteLine( "disp-" + HashIdent() + disposing.ToString() ); and the following code to the TestGC form class. public readonly string testGCSource; public TestGC( string testGCSource ) : this() { this.testGCSource = testGCSource; this.Text = HashIdent(); System.Diagnostics.Debug.WriteLine( "ctor." + HashIdent() ); } public TestGC() { this.testGCSource = String.Empty; InitializeComponent(); } private string HashIdent() { return String.Format( "TestGC:{0}[{1}]", this.testGCSource, this.GetHashCode() ); } private void buttonShow_Click( object sender, EventArgs e ) { (new TestGC( "Show" )).Show(); } private void buttonShowDialog_Click( object sender, EventArgs e ) { (new TestGC( "ShowDialog" )).ShowDialog( this ); } private void buttonCollect_Click( object sender, EventArgs e ) { this.textBoxMemory.Text = System.GC.GetTotalMemory( true ).ToString("N0"); } ~TestGC() { System.Diagnostics.Debug.WriteLine( "dtor~" + HashIdent() ); } What the simple test app demonstrates is that a form and all of its controls when displayed using the Show() method are NEVER destructed, they are Disposed(true) but not ever destructed. That is the class instance once created is never destroyed. This seems to be a total disaster (obviously not here, but for complex, multi-paged forms with perhaps hundreds of controls in mdi projects with many hundreds of forms) and is by every definition an example of a true memory leak. (The ShowDialog display method on form Close does call the destructor and gets fully GC'ed). So my questions - Is there any way to request of the GC why it will not specifically Finalize a class instance? Is there any way to force the GC to Finalize (destruct) a Windows component? (Form + Controls). (ie Is there a WinApi type dll call to force the Form (+ Controls) to go out of scope and be GC'ed? From the above code it is obvious there are no 'local' references to any component after th

    C# visual-studio debugging performance tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups