outofmemoryexception was unhandled with pictures

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • djpaul
    New Member
    • Oct 2006
    • 137

    outofmemoryexception was unhandled with pictures

    Hello,
    For my neighbour i am creating a photoalbum.
    But when i load more then 110 photo's in a flowlayoutpanel with pictureboxes i get the error outofmemoryexce ption was unhandled.
    Do i need to resize the picture before loading them or can i do something else?

    This is my code for loading:
    Code:
    Dim Table As DataTable
            Dim i As Integer
    
            FlowLayoutPanel1.Controls.Clear()
    
            Dim SQL As String = "SELECT fotonaam, fotomap, textveld FROM foto WHERE (fotomap = '" & Replace(CmbPath.Text, "'", "''") & "');"
    
            Table = SelectQuery(SQL)
            Dim ThumbPicturearr(Table.Rows.Count) As PictureBox
    
    
            While Table.Rows.Count <> i
    
                ThumbPicturearr(i) = New PictureBox
                ThumbPicturearr(i).Name = "Foto" & i
                ThumbPicturearr(i).Height = 134
                ThumbPicturearr(i).Width = 164
                ThumbPicturearr(i).BackColor = Color.DarkGray
                ThumbPicturearr(i).Image = Image.FromFile(Table.Rows(i).Item("fotomap") & "\" & Table.Rows(i).Item("fotonaam"))
                ThumbPicturearr(i).SizeMode = PictureBoxSizeMode.Zoom
                ThumbPicturearr(i).BorderStyle = BorderStyle.Fixed3D
    
                FlowLayoutPanel1.Controls.Add(ThumbPicturearr(i))
                i = i + 1
    
            End While
            Table.Dispose()
    Regards, Paul
  • joedeene
    Contributor
    • Jul 2008
    • 579

    #2
    since you have the while and end while, thats probably what runs out of memory, try creating a new thread with the actions to perform and set the threadname.isba ckground property to true

    Comment

    • djpaul
      New Member
      • Oct 2006
      • 137

      #3
      Hmm, that doesn't seems like no sense to me for using another method for the while.
      Okay, i tried:
      Code:
      For i = 0  To Table.Rows.count
      
      'stuff
      
      Next i
      But same error occures.
      And what did you mean by the isbackground property? the ThumbPictureArr ?

      Gr Paul

      Comment

      • joedeene
        Contributor
        • Jul 2008
        • 579

        #4
        Originally posted by djpaul
        Hmm, that doesn't seems like no sense to me for using another method for the while.
        Okay, i tried:
        Code:
        For i = 0  To Table.Rows.count
        
        'stuff
        
        Next i
        But same error occures.
        And what did you mean by the isbackground property? the ThumbPictureArr ?

        Gr Paul
        like create a new thread, to the addressof a sub that performs the actions you want, in your case either the
        Code:
        For i = 0  To Table.Rows.count
        
        'stuff
        
        Next i
        method or the previous one. umm the .isbackground property is a property of a thread so example

        Code:
            Dim mythread As Threading.Thread = New Threading.Thread(AddressOf backgroundactionsthread)
            Private Sub subonmainthread()
                mythread.IsBackground = True
                mythread.Start()
            End Sub
            Private Sub backgroundactionsthread()
                For i = 0 To Table.Rows.count
        
                    'stuff
        
                Next i
            End Sub
        so move the code inside the "subonmainthrea d" sub to wherever, such as on a button click event or wherever it suits you, pretty simple...tell me if you need more help...

        *Threads are dangerous for beginners, please be sure to make sure that your threads close properly, when either in debugging or built already...but they arent too bad...(threads close automatically when events/actions are accomplished...

        Comment

        • FastestFasteris
          New Member
          • Jan 2011
          • 1

          #5
          Freed teen porn video

          Raw forgive go setting with na‹ve relations! http://teens-model.com

          Comment

          Working...