473,323 Members | 1,551 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,323 software developers and data experts.

VB.NET Service + Out of Memory

I have a vb.net service which copies images and resizes images from a local
directory to a remote one.

When I drop images into the local directory I get an out of memory error
after several images - the exception is on the following line.

Dim img As Image = Image.FromFile(path)

The machine has a GB of ram, and there is not a great deal running.
Each image is about 2000 x 2000 PIXELS

Thanks for any help in advance
Jun 28 '06 #1
2 1155

Rocky wrote:
I have a vb.net service which copies images and resizes images from a local
directory to a remote one.

When I drop images into the local directory I get an out of memory error
after several images - the exception is on the following line.

Dim img As Image = Image.FromFile(path)

The machine has a GB of ram, and there is not a great deal running.
Each image is about 2000 x 2000 PIXELS

Thanks for any help in advance


Hmm... My guess would be that you aren't calling Dispose on the image
object. Just setting it to nothing will not free the native memory
used by the image. Of course, with out seeing the actuall code for
this routine, I am only guessing :)

--
Tom Shelton [MVP]

Jun 28 '06 #2
Hi Tom,

Here is the copy of the code

Dim asr As AppSettingsReader = New AppSettingsReader
Dim sRemoteDirectory As String = CType(asr.GetValue("RemoteDirectory",
GetType(String)), String)

Dim sBackupDirectory As String = CType(asr.GetValue("BackupDirectory",
GetType(String)), String)

Dim img As Image = Image.FromFile(path)

Dim imgFormat As Imaging.ImageFormat = GetImageFormat(path)

'Maintain aspect ratio

Dim scale As Double = 0

Dim width, height As Integer

width = CType(asr.GetValue("ImageWidth", GetType(String)), Integer)

height = CType(asr.GetValue("ImageHeight", GetType(String)), Integer)

'Caters for the user specifying 0 for either width or height

If width = 0 Then

width = 1

ElseIf height = 0 Then

height = 1

End If

If img.Height < img.Width Then

scale = width / img.Width

Else

scale = height / img.Height

End If

Dim newwidth As Integer = CInt(scale * img.Width)

Dim newheight As Integer = CInt(scale * img.Height)

Dim bmp As New Bitmap(img, newwidth, newheight)

img.Dispose()

'Add a log entry

SaveToLog(filename)

Dim sRemotePath As String = String.Format("{0}\{1}", sRemoteDirectory,
filename)

bmp.Save(sRemotePath, imgFormat)

bmp.Dispose()

Dim sBackupPath As String = String.Format("{0}\{1}", sBackupDirectory,
filename)

File.Copy(path, sBackupPath, True)

File.Delete(path)
"Tom Shelton" <to*@mtogden.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...

Rocky wrote:
I have a vb.net service which copies images and resizes images from a
local
directory to a remote one.

When I drop images into the local directory I get an out of memory error
after several images - the exception is on the following line.

Dim img As Image = Image.FromFile(path)

The machine has a GB of ram, and there is not a great deal running.
Each image is about 2000 x 2000 PIXELS

Thanks for any help in advance


Hmm... My guess would be that you aren't calling Dispose on the image
object. Just setting it to nothing will not free the native memory
used by the image. Of course, with out seeing the actuall code for
this routine, I am only guessing :)

--
Tom Shelton [MVP]

Jun 29 '06 #3

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

Similar topics

8
by: Greg Merideth | last post by:
I've written a basic windows service to provide some helper xml functions for my web methods and even thou the service is only about 1k lines long with 1 timer, its mem usage is 10m and its vm mem...
8
by: nautonnier | last post by:
I know my problem has been discussed ad nauseum but I still don't get it so please bear with me. I have written a service which performs some work against a database once a day (usually in the...
7
by: HeatherS | last post by:
We are having issues with our windows services using memory and never releasing it. We have one service that has a file watcher which takes an xml file, inserts some records into a database, and...
9
by: Ryan Liu | last post by:
Hi, I use C# wrote an Client/Server application. In production environment, will be 130 clients (Windows XP) connect to a Server (Windows 2000/2003 Server) thought TCP/IP socket in a local 100M...
5
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post by:
Hi All, I am using asp.net session state service to store session. The concurrent online user will be almost 2000. Could asp.net session state service afford this? Is there any limitation...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.