473,395 Members | 1,668 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Intermittent 'Out of memory' error

I have a VB .NET windows application that is throwing an intermittent
'out of memory' error. Here is the call stack.

Out of memory.

at System.Drawing.Graphics.FromHdcInternal(IntPtr hdc)
at System.Windows.Forms.DibGraphicsBufferManager.Crea teBuffer(IntPtr
src, Int32 offsetX, Int32 offsetY, Int32 width, Int32 height)
at
System.Windows.Forms.DibGraphicsBufferManager.Allo cBuffer(Graphics
targetGraphics, IntPtr targetDC, Rectangle targetBounds)
at System.Windows.Forms.DibGraphicsBufferManager.Allo cBuffer(IntPtr
target, Rectangle targetBounds)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam) Source = System.Drawing

The program uses our own timer form that gives a countdown between each
processing cycle. Each processing cycle looks for reports that need
running from 3 SQL Server 2000 databases (don't ask why there are
three). Also, once a day it does a bcp load of data into each of the 3
database and runs various snapshot tasks.

I don't think the details are important besides to say it is doing a
fair amount of processing.

The question is, is this likely to be caused by memory leakage. Sounds
like it to me but I thought that I'd find out if anybody else gets this
error. The call stack is always the same but it fails at various times
of day but sometimes not for 2 weeks.

I have been monitoring the memory usage and it does go up gradually
over time from 120Mb to 150Mb. I have added garbage collection calls to
no effect.

The program uses COM in various places.

Any advice greatly appreciated.

Jul 18 '06 #1
2 2276
Liverpool fan,

Have a look about all that is written about dispose on MSDN to clean up your
not managed resources.

http://msdn.microsoft.com/library/de...posemethod.asp

http://msdn.microsoft.com/library/de...izeDispose.asp

Using the dispose methods implemented in the managed classes will probably
not help you as well as calling the gc for the same,

I hope this helps,

Cor
"Liverpool fan" <ch*********@feltex.comschreef in bericht
news:11*********************@m73g2000cwd.googlegro ups.com...
>I have a VB .NET windows application that is throwing an intermittent
'out of memory' error. Here is the call stack.

Out of memory.

at System.Drawing.Graphics.FromHdcInternal(IntPtr hdc)
at System.Windows.Forms.DibGraphicsBufferManager.Crea teBuffer(IntPtr
src, Int32 offsetX, Int32 offsetY, Int32 width, Int32 height)
at
System.Windows.Forms.DibGraphicsBufferManager.Allo cBuffer(Graphics
targetGraphics, IntPtr targetDC, Rectangle targetBounds)
at System.Windows.Forms.DibGraphicsBufferManager.Allo cBuffer(IntPtr
target, Rectangle targetBounds)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32
msg, IntPtr wparam, IntPtr lparam) Source = System.Drawing

The program uses our own timer form that gives a countdown between each
processing cycle. Each processing cycle looks for reports that need
running from 3 SQL Server 2000 databases (don't ask why there are
three). Also, once a day it does a bcp load of data into each of the 3
database and runs various snapshot tasks.

I don't think the details are important besides to say it is doing a
fair amount of processing.

The question is, is this likely to be caused by memory leakage. Sounds
like it to me but I thought that I'd find out if anybody else gets this
error. The call stack is always the same but it fails at various times
of day but sometimes not for 2 weeks.

I have been monitoring the memory usage and it does go up gradually
over time from 120Mb to 150Mb. I have added garbage collection calls to
no effect.

The program uses COM in various places.

Any advice greatly appreciated.

Jul 18 '06 #2
Thanks for replying Cor. I has already tried enforcing a Garbage
Collection which seemed to help to an extent but only to decrease the
frequency of the error. I'll have a look at the articles and compare to
what I am doing already as far as COM is concerned.

Here is the Timer calling routine. I have changed it slightly in that
instead of creating a new timer dialog for each loop, I reuse the
previous one. This seems to have helped immensely but I now have a 4K
creeping of memory usage for each loop (when nothing is executed).

Private Sub StartTimer()

Dim dtloadfull, dtjobscan As Date
Dim sLoadFull As String = "Load Sales Extract"
Dim sprocessjobs As String = "Process Job Queue"

Me.ListBox1.Items.Add("Started " & Date.Now.ToString)
Me.ListBox1.SelectedIndex = Me.ListBox1.Items.Count - 1

' next order scan
dtjobscan = DateAdd(DateInterval.Minute, myJobScanInterval,
Now)

' launch the timer
f = New dlgZTimer
f.TimerIntervalSecs = 1

Do
'Clean up memory
GC.Collect

' get time of next full update. may be next day.
If myFullLoadTime = "" Then
dtloadfull = Nothing
Else
dtloadfull =
System.Convert.ToDateTime(Now.ToShortDateString & " " & myFullLoadTime)
Do While dtloadfull < Now
dtloadfull = DateAdd(DateInterval.Day, 1,
dtloadfull)
Loop
Me.lblProgress.Text = "Progress (" & "Next full
extract load at " & dtloadfull.ToString & ")"
Application.DoEvents()
End If

' next order scan
dtjobscan = DateAdd(DateInterval.Minute, myJobScanInterval,
Now)

f.TimerTitle = ""

If myFullLoadTime = "" Then
f.TimerTitle = sprocessjobs
f.TargetTime = dtjobscan
Else
' if full load is in the next 10 minutes, wait for it
If dtloadfull <= DateAdd(DateInterval.Minute, 10, Now)
Then
f.TimerTitle = sLoadFull
f.TargetTime = dtloadfull
Else
' no trans available, check for orders
f.TimerTitle = sprocessjobs
f.TargetTime = dtjobscan
End If
End If

If f.TimerTitle <"" Then

If f.ShowDialog(Me) = DialogResult.OK Then
If f.TimerTitle = sprocessjobs Then

If myMultiThreaded = True Then
ProcessJobQueueMultiThreaded()
Else
ProcessJobQueue()
End If
' test for network connection
If myLastNetworkCheck < Now.AddHours(-1) Then
Try
DisplayHistory("******** Testing
network connection")
Dim str As String()
str =
System.IO.Directory.GetFiles(myBCP_Full_Directory)
myLastNetworkCheck = Now
Catch ex As Exception
DisplayErrorInList(ex)
End Try
End If

End If

If f.TimerTitle = sLoadFull Then
ProcessEOD()

' test to see if EOD data has been loaded
CheckEODStatus()
End If
Else
' Cancelled
f.Dispose()
f = Nothing
Exit Sub
End If
End If
Loop

End Sub

I have focussed on this because of the rate that the memory was being
used up even when the program wasn't doing anything but running the
timer. Seemed to be a prime candidate.

Any thoughts greatly appreciated.

Jul 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Bill Burwell | last post by:
Which memory properties, or what combinations of memory properties, provide useful information about a program's memory usage when that program has just started leaking memory? While I have...
1
by: bloodhound | last post by:
Hi, Problem with global.asa not firing 100% of the time. This error crops up several times throughout the day but if you wait a while and reload the page (could be 5 mins or an hour) it will...
0
by: deevoy | last post by:
Hi- I'm developing a asp.net web application and everything has proven fine on the dev and acceptance environment. We've moved the code up to our windows server 2003 prod environment and get the...
3
by: Lee Chapman | last post by:
Hi, I have a problem where my ASP.NET application occasionally generates a MissingFieldException exception. This unexpectedly happened on my development box, and so I was able to extract some...
1
by: deevoy | last post by:
Hi- I'm developing a asp.net web application and everything has proven fine on the dev and acceptance environment. We've moved the code up to our windows server 2003 prod environment and get...
9
by: Tim_Mac | last post by:
hi, i'm not sure if i have chosen the best approach, but it seemed quite good to me. i have a collection class, containing business objects. the collection class is static and remains in-memory...
8
by: Dave | last post by:
I am getting an intermittent database error on my asp page. I am using Access 2003 with classic ASP. The error is this: Microsoft JET Database Engine Error 80040e10 No value given for one or...
4
by: steve_barker333 | last post by:
Hi guys! I keep getting the following error reported by VS 2005 in my ASP.NET 2.0 web project: "The type or namespace name 'MainPages_XXX' could not be found (are you missing a using...
0
by: Joey Bersche | last post by:
I've been experiencing an intermittent crash where no python stacktrace is provided. It happens for a url downloading process that can last up to 12 hours and crawls about 50,000 urls. I'm...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.