Memory Limits? RRS feed

  • Question

  • Are there any memory limits other than physical memory for .net applications? I am getting out of memory errors at only 40MB. How much is vshost able to use and how much is reserved for windows? I am running VS 2012 express on a 2GB Windows 10 TC virtual machine. Here is a screenshot showing how little memory it takes to get an out of memory error, I have 52% free, why can't it use that?

    Is there any way to allocate my application more memory?

    • Moved by Amanda Zhu Friday, December 26, 2014 6:54 AM not vs general issue, it is more related to program
    Saturday, December 6, 2014 4:45 AM


All replies

  • This error does not necessary mean a memory deficiency:

    Try investigating the exception details and finding the problematical place.

    Saturday, December 6, 2014 8:17 AM
  • I'm using file stream, not image.fromfile. FromFile just links the image variable to the file creating a file in use exception when trying to reopen the image. (Which is very likely to occur)

    Basically I'm making a skinning system for a game that imitates a real operating system with super customizable setting (you can change the title bar image, close buttons font and almost everything else)

    The game loads the images into public variables when started and saves them to a file each time the apply button is pressed, overwriting the old ones. The setting are saved a dat file. if there are no save file(s) then the default setting are loaded.

    After customizing after the first boot (no save files - using defaults) they are no memory errors, but after restarting the games, simply opening the shifter can cause a memory error. Is there something wrong with the way I am saving or opening the images files?

    ' Loading images
    Dim fs As FileStream
            If File.Exists(savepath + "Shiftum42\Skins\Loaded\titlebar") Then
                fs = New FileStream(savepath + "Shiftum42\Skins\Loaded\titlebar", FileMode.Open, FileAccess.Read)
                titlebar = Image.FromStream(fs)
            End If
    ' Saving images
    saveimage(titlebar, "titlebar")
    ' ----
    Private Sub saveimage(ByVal img As Image, ByVal name As String)
            If Not IsNothing(img) Then
                If File.Exists(savepath + "Shiftum42\Skins\Loaded\" & name) Then File.Delete(savepath + "Shiftum42\Skins\Loaded\" & name)
                    img.Save(savepath + "Shiftum42\Skins\Loaded\" & name, System.Drawing.Imaging.ImageFormat.Png)
                Catch ex As Exception
                    infobox.showinfo("Saving Error", "Opps, an error occured when saving the file " & savepath + "Shiftum42\Skins\Loaded\" & name & ". Please contact DevX to report the problem.")
                End Try
                If File.Exists(savepath + "Shiftum42\Skins\Loaded\" & name) Then File.Delete(savepath + "Shiftum42\Skins\Loaded\" & name)
            End If
        End Sub

    The images variables are set to a file chosen by the  user when they are skinning ShiftOS (game name)

    Images are in png format, I just haven't added an extension as it doesn't need one and it is easier to use the same name as the variable.
    • Edited by william.1008 Thursday, December 18, 2014 9:51 AM
    Thursday, December 18, 2014 9:46 AM
  • Have you determined which line of your game causes the exception? (E.g. run in Debug mode, analyse the error dialog and the call stack etc.).

    Thursday, December 18, 2014 10:00 AM