Advertisement

09.19.2008 at 10:16AM PDT, ID: 23746644 | Points: 500
[x]
Attachment Details

Program Consuming too much Virtual Memory

Asked by luftmensch777 in Visual Basic Programming, Computer Memory (RAM), Debugging Software for Development

Tags:

I have a program that, essentially, takes several tiff files and combines them into a single document and then saves them to another location.  The program use to run for several hours, and then give me a virtual memory error and I would have to stop the program and restart my computer.  I would then run the program again so it would pick up where it had left off.  There are nearly 30 gigs of files it needs to go through, so I would have to do this a bunch of times.  Recently I had to delete all the files my program had created and have it start again.  Now the program only runs for 20 minutes or so and then it bombs out with that same memory error.  Is there a way to get my program to stop consuming so much virtual memory?  Or can I make it so that when it is done copying a new tiff file to its new location; it will release it from memory?  Is there anything else I can do, besides getting more ram, which will stop this error from happening, or at least from happening so often?Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
Imports System.Collections.ObjectModel
Imports System.Drawing.Imaging
Imports System.IO
 
    Sub CombineFilesAndCopy()
        If Not My.Computer.FileSystem.DirectoryExists("S:\WI Viewer Tiff Files\" & Microsoft.VisualBasic.Left(myFile, 2)) Then
            My.Computer.FileSystem.CreateDirectory("S:\WI Viewer Tiff Files\" & Microsoft.VisualBasic.Left(myFile, 2))
        End If
 
        k = i
        '   Dim filename As String = "Q:\" & Microsoft.VisualBasic.Left(myFile, 2) & "\" & myFile & ".tif"
        'get the codec for tiff file
        Dim info As ImageCodecInfo = Nothing
        Dim ice As ImageCodecInfo
        For Each ice In ImageCodecInfo.GetImageEncoders()
            If ice.MimeType = "image/tiff" Then
                info = ice
            End If
        Next ice 'use the save encoder
 
        Dim enc As Encoder = Encoder.SaveFlag
        Dim encCom As Encoder = Encoder.Compression
 
        Dim ep As New EncoderParameters(2)
        ep.Param(0) = New EncoderParameter(enc, CLng(EncoderValue.MultiFrame))
        ep.Param(1) = New EncoderParameter(encCom, CLng(EncoderValue.CompressionCCITT4))
 
        Dim pages As Bitmap = Nothing
        Dim frame As Integer = -1
 
        Do
            k = k + 1
            frame += 1
            If frame = 0 Then
                pages = CType(Image.FromFile(Systemfiles(k - 1).ToString()), Bitmap)
                'save the first frame
                '  ep.Param(0) = New EncoderParameter(enc, CLng(EncoderValue.FrameDimensionPage))
                pages.Save(filename, info, ep)
            Else
                Try
                    'save the intermediate frames
                    ep = New EncoderParameters(2)
                    ep.Param(0) = New EncoderParameter(enc, CLng(EncoderValue.FrameDimensionPage))
                    ep.Param(1) = New EncoderParameter(encCom, CLng(EncoderValue.CompressionCCITT4))
                    pages.SaveAdd(CType(Image.FromFile(Systemfiles(k - 1).ToString()), Bitmap), ep)
                Catch ex As Exception
                    Console.WriteLine(ex.Message)
 
                End Try
 
            End If
            If k = Systemfiles.Count Then Exit Do
        Loop Until Microsoft.VisualBasic.Right(Microsoft.VisualBasic.Left(Systemfiles(k).ToString(), 18), 12) <> myFile
        CurrentRev.Add(myFile)
        pages.Dispose()
        ep.Dispose()
    End Sub
Attachments:
 
Visual Studio's Error Message Info
 
[+][-]09.19.2008 at 10:48AM PDT, ID: 22523623

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.19.2008 at 11:47AM PDT, ID: 22524149

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.19.2008 at 12:24PM PDT, ID: 22524527

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.23.2008 at 11:59AM PDT, ID: 22552732

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.23.2008 at 02:31PM PDT, ID: 22554342

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.25.2008 at 09:56AM PDT, ID: 22571457

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.25.2008 at 01:13PM PDT, ID: 22573410

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.26.2008 at 05:39AM PDT, ID: 22578805

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.26.2008 at 07:45AM PDT, ID: 22580024

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.26.2008 at 12:55PM PDT, ID: 22583130

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.26.2008 at 02:33PM PDT, ID: 22584036

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.07.2008 at 01:29PM PDT, ID: 22663426

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.07.2008 at 02:27PM PDT, ID: 22663984

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.13.2008 at 08:19AM PDT, ID: 22703169

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628