|
I just noticed that the memory keeps building up when i go from title search screen to title detail screen and when i go back and forth again and again the memory keeps building up and eventually the system crashes.
|
|
|
|
|
I strongly suggest you fix the memory problem first; I expect the other problem
will no longer exist.
Are you disposing of every disposable class you instantiated? (such as dialogs)
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi thanks, the application does not really uses dialogs and yes I am disposing all the classes. I have monitored the memory for whole day today doing various activities. the titledetail screen is a heart of application and has lots of controls eg. label, textbox etc. the application seem to crash when the memory usage reaches around 80,000k or above. if the application is minimised it falls down to around 1000-7000k memory. when the titledetail is again maximised it jumps from 1000-7000 to around <40000k which means there are still 40000k extra memory before the system crashes. could you please point me to right solution so that i could over come this problem as i cant ask users to minimise the application when not necessary instead of toggling in between various applications.
Bikash
|
|
|
|
|
Hi,
if memory falls back to less than 10MB every time you minimize, then that is
very good; the gc is called when you minimize; it will also get called when
there is a need to, and you seem to have proven it will effectively free most memory.
there is not much I can do, since I don't really know your app.
repeat from 2 days ago:
If you decide to persue this further on this forum, you may want to provide
more information with respect to:
- threads; what do you use, what for, ... <<<<<<<<<<<<<<<<<<<<<
- AppDomains; dito <<<<<<<<<<<<<<<<<<<<<
- memory situation
- circumstances of crash
You once mentioned "each windows control is not a form its a windows control which
is rentered in a main form." but I don't understand what you are saying here.
Can you clarify?
Some more questions:
- what is your .NET version?
- what is your OS?
- how much RAM memory is there?
- what would be the biggest objects? and how many typically?
- do you have large unmanaged memory blocks (either allocated by native code,
as in malloc(), or native data structures behind managed objects you are aware of?
- do you use double buffering? for all controls? how? do you do it yourself, if
so provide details; or do you use double-buffering as built-in in .NET 2.0?
(maybe this takes a lot of unmanaged memory)
- do you use P/Invoke at all?
- are you pinning objects?
- are you calling the garbage collector explicitly? if so, explain how and why.
- are there special things involved: databases, reflection, XML, ...
- did you feel the need to do special things that you maybe don't really understand
but that seemed necessary to get around some problems?
- how big is your app? how many hundreds/thousands of lines of code?
- how many of those "xceed grid control"s do you instantiate?
Could you show some of the complex forms? when you say "a lot of controls"
I may not have the same idea you do about "a lot".
Do you have logging installed, so you can trace which major objects get created,
which methods get executed, etc? if not, that is what I would do. In fact, I
always do that from the beginning, it always pays off, it even saves a lot of
development time; the simplest log method takes a string, prefixes the
current time, and prints it on the debug console.
Hope this helps.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi!
My .NET version is 1.1.4322 SP1 / Windows XP, 2GB RAM.
Instead of using windows form we have used windows usercontrols. which are then rendered into a single container.
in each usercontrol a dispose method is called to clean up as below
------
#Region "Cleanup"
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If Not (myIsDisposed) Then
Try
If disposing Then
' Release the managed resources you added in
' this derived class here.
myCurrTitle = Nothing
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
' Release the native unmanaged resources you added
' in this derived class here.
myIsDisposed = True
Finally
' Call Dispose on our base class.
MyBase.Dispose(disposing)
End Try
End If
End Sub
' This derived class does not have a Finalize method
' or a Dispose method without parameters because it
' inherits them from the base class.
#End Region
------
the memory seems to just increase and at certain stage the application crashes when it reaches its peak. is there any tools out there so that i can track what type of memory leakage is it i.e. stack, unmanaged or managed so that i could go in right direction.
I am not sure about biggest object. I think it could be the xceed grid control( not sure).
no i dont use double buffering. yes there databases, refletion and xml. but it seems that it has nothing to do with database or xml or reflection.
in this titldetail control about 15000 lines of code. when the titledetail is loaded in subtabs all together about 5-6 xceed grid control is loaded.
there may be about 200-400 controls including labels, textboxes, grids etc.
could you please point me to right direction.
|
|
|
|
|
This is what I would do:
1. try to get line numbers in the exeception details, by running a debug build, not a release
build, and keeping the PDB files.
2. try to get to upgrade the app to .NET 2.0
3. simplify the OnThreadException() method that is mentioned in the exception traceback:
at HCA.SalesRep.AppContainer.frmContainerThreadExceptionHandler(...)
at System.Windows.Forms.ThreadContext.OnThreadException(Exception t)
so that 1) you know where and why it occurs, 2) it does not create a problem on its own.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
the project consitutes 5 dlls namely
appstart.exe
appcontainer.dll - a container that holds all the user controls
comms.dll - database layer
basectrl.cll - the parent template
screens.dll - all the user controls this is a main project that i work on.
frmContainerThreadExceptionHandler when thrown logs a exception detail into database. but for this exception it didnt log a exception.
why do you think upgrading .net 2.0? do you think it might fix this memory leakage problem? if yes how can i do that upgrade? i currenly run all project in visual studio 1.1.
thanks for all your help so far.
|
|
|
|
|
From the exception's traceback I can see it crashes inside frmContainerThreadExceptionHandler,
so if you don't see it in the database, it did crash before you write it out.
Try adding a Console.WriteLine(myException.ToString()) at the very start of the exception
or something similar (maybe just write to a new text file).
I see frmContainerThreadExceptionHandler is trying to create an ErrorForm and failing at it;
can you show its constructor code?
For a big project having problems I would consider upgrading to 2.0 since a couple of things
have improved, I recon exception handling is one of them. Anyway, I don't expect MS to
fix all bugs they still find in all older versions. If you decide to do it you will need:
- Visual Studio 2005 (the free Express Edition or other);
- 2.0 versions of all third-party stuff if any;
- to reopen your project and let the wizard convert it;
- I expect 99% of code to be compatible; a few classes got their method names or signatures
modified, the first build attempt will point them out.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi!
below is the code
-----
Private Sub ThreadExceptionHandler(ByVal sender As Object, ByVal t As System.Threading.ThreadExceptionEventArgs)
' This is our default, catch all exception handler
' get the stacktrace object for this exception
Dim stack As New System.Diagnostics.StackTrace(t.Exception)
Dim i As Integer
Dim files As New Hashtable
Dim file As DictionaryEntry
Dim errFrm As ErrorForm
Dim fileStr As String
If Not Me.Disposing Then
' create a hashtable of files and versions involved
For i = 0 To stack.FrameCount - 1
If Not files.ContainsKey(stack.GetFrame(i).GetMethod.DeclaringType.Assembly.Location) Then
files.Add(stack.GetFrame(i).GetMethod.DeclaringType.Assembly.Location, _
stack.GetFrame(i).GetMethod.DeclaringType.Assembly.GetName.Version.ToString)
End If
Next
For Each file In files
fileStr += file.Key & " - " & file.Value & vbCrLf
Next
errFrm = New ErrorForm
If Not t Is Nothing Then
errFrm.messageLbl.Text = t.Exception.Message
errFrm.stacktraceTxt.Text = t.Exception.ToString & vbCrLf
Else
errFrm.messageLbl.Text = "Invalid exception trapped by default handler"
errFrm.stacktraceTxt.Text = "Not available"
End If
If Not Me.IsDisposed Then
'Mailer.Send(t.Exception.ToString & vbCrLf & fileStr, "Computer name: " & System.Environment.MachineName & _
' vbCrLf & "User name: " & System.Environment.UserName & vbCrLf)
LogError(Strings.Left(t.Exception.ToString & vbCrLf & fileStr, 7000))
errFrm.filesTxt.Text = fileStr
errFrm.ShowDialog(Me)
errFrm.Dispose()
End If
stack = Nothing
End If
End Sub
-----
since this code lies in appcontainer.dll but i can only run the project from screens.dll I am not sure how could i trace the error or do console.writeline from screen
please help
|
|
|
|
|
Hi,
thanks, but I asked for the ErrorForm constructor code...
uglyeyes wrote: since this code lies in appcontainer.dll but i can only run the project from screens.dll I am not sure how could i trace the error or do console.writeline from screen
?? not sure what you are saying here ??
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I forgot to mention this. each time i hit the title to go to title detail screen. in console it throws this msg
The thread '<no name="">' (0x2378) has exited with code 0 (0x0) and it keeps building up for each event (i.e clicking the title to get to title detail screen) and at the end it crash. so below is the output of the debug msg.
The application crashed when i try to see the title detail in 16th time
The thread '<no name="">' (0x2378) has exited with code 0 (0x0).
The thread '<no name="">' (0x26e8) has exited with code 0 (0x0).
The thread '<no name="">' (0x22fc) has exited with code 0 (0x0).
The thread '<no name="">' (0x25b4) has exited with code 0 (0x0).
The thread '<no name="">' (0x1fd4) has exited with code 0 (0x0).
The thread '<no name="">' (0x1dc4) has exited with code 0 (0x0).
The thread '<no name="">' (0x21d0) has exited with code 0 (0x0).
The thread '<no name="">' (0x1a8c) has exited with code 0 (0x0).
The thread '<no name="">' (0x11c0) has exited with code 0 (0x0).
The thread '<no name="">' (0x2234) has exited with code 0 (0x0).
The thread '<no name="">' (0x24cc) has exited with code 0 (0x0).
The thread '<no name="">' (0x269c) has exited with code 0 (0x0).
The thread '<no name="">' (0x2394) has exited with code 0 (0x0).
The thread '<no name="">' (0x1814) has exited with code 0 (0x0).
The thread '<no name="">' (0x18b4) has exited with code 0 (0x0).
An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in HCA.SalesRep.AppContainer.exe
Additional information: Error creating window handle.
The program '[9756] HCA.SalesRep.AppContainer.exe' has exited with code 0 (0x0).
|
|
|
|
|
Not sure what you mean by errorform constructor code. i believe this..
Public Class ErrorForm
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
mLoadTime = Date.Now
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
.....
|
|
|
|
|
OK,
I think the problem you are having is caused by doing the ErrorForm stuff on a thread
that is not the main thread. When you do that on .NET 1.1 the app may hang, or the GUI
may fail to behave normally at any time; when you do that on .NET >= 2.0 you will get
an InvalidOperationException mentioning a "cross-thread-violation".
What you need to do is make sure the GUI-related code (that includes everything concerning
ErrorForm) to execute on the GUI thread; that is exactly the purpose of the
Control.InvokeRequired property and the Control.Invoke() method. I also would consider
creating the ErrorForm only once at app initialization, and populating and showing then
hiding it when appropriate (through Invoke).
As I said before, a more recent .NET version helps you in recognizing this kind of
faulty situation long before it causes trouble.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
do you think is that why the memory is not freeing up? do you think this is whats causing the whole thing? each time i go from title to title detail it increases the memory by around 5mb and even when i go back it doesn't free the memory up.
|
|
|
|
|
I don't know about your memory situation; I do know any app that violates the "every control
should only be accessed by the thread that created it" rule will behave badly, it may
freeze the GUI, hang completely, or (for a while) seem to function normally; whatever the
symptoms, it can not be trusted.
If you violate the rule, first thing to do is fix it. Everything else that remains has
to be handled thereafter.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
hiii
need to know how can i disable some combination of keys using vb2005
example ctrl+shift+y while my program is running
but there is a tool i used in my program use this shortcut(ctrl+shift+y) ?????????????
thank you
|
|
|
|
|
I'm not really sure about this but try looking in to using the event of KeyPress on you form.
in C# you'd get teh event with something like this.KeyPress+=new K...
|
|
|
|
|
thank you Mr Rocky71
I did but in vain , i do not know what is the problem
thank you
|
|
|
|
|
I want to learn how to make an application like Shaderman in which we have blocks representing code and which we link together with lines. How are these block build? How are the lines being drawn? Did they use graphics 2d in C# to make the blocks and lines? Where could I find information?
|
|
|
|
|
You can get the code here[^]. Enjoy.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
You're removing all the fun now...
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Have you taken a look at what it's written in? Python - I figured that was mockery enough right there.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
OK, we're all set for another batch of jokes on rabbits, knights who say nih,
shrubberies, Castle of Anthrax, etc.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
"What is your favorite color?"
|
|
|
|
|
I'm not sure, but it aint ColorControlPaint.DarkDark(Color.White)
PS: trying to keep this a programmer's forum
-- modified at 10:21 Thursday 16th August, 2007
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|