locked
Query Memory Problems Windows 8 Visual Studio Express 2013

    Question

  • I have written a very long and quite complicated card game called Contract Rummy which keeps hanging or freezing for no reason that I can relate to the code. It has many loops for different actions which are used repeatedly by all four players. It will usually play fine for four of the contracts/rounds, although even when on the fourth one I notice, now, that it is slowing down. Each contract uses the same code so if one works they should all work. However between round 5 and 7 it will invariable hang always in different places at some point - just stops for no reason. I have once managed to play all 7 rounds, perhaps because the bots found the cards they wanted quickly and so did not have to go through so many loops.

    Having checked the code 5,000 times am I right in thinking this is a running out of memory problem? If so would be most grateful if anybody could suggest how I can solve it.

    Many thanks in advance

    Malcolm Bain


    Malcolm Bain

    Tuesday, May 13, 2014 12:51 PM

Answers

  • I recommend that you open a support case at this time.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, May 15, 2014 7:10 PM
    Moderator

All replies

  • There isn't enough information to say if this is a memory leak or not. You'll need to debug to find more. Is this a hard hang or les it just get slow? What does the memory usage look like?

    See Analyze the performance of Windows Store apps using Visual Studio diagnostic tools for information on using Visual Studio's diagnostic tools to profile the memory use. You can also use tools such as PerfView. See http://channel9.msdn.com/Series/PerfView-Tutorial

    Tuesday, May 13, 2014 2:39 PM
    Owner
  • Thank you,

    I have never looked at the memory usage or knew how to do so. I will have a go with the tools you have told me about.

    It does not crash giving me anything from the debugger it just does a hard hang - cannot do anything with it. I can only guess where it has hung by looking at information labels for the player which usually shows what should be going to happen at the time it hangs. Always different areas and not appearing until approximately half way through a game. As I said, I did notice that half way through a game it seem to be doing everything slower.

    Is there any code I can use to free up memory between hands which is what I feel I need to do?

    I will let you know how I get on with the tools.

    Malcolm

     


    Malcolm Bain

    Tuesday, May 13, 2014 3:32 PM
  • I ran the debugging diagnostics and although I could not understand most of the results it does seem I have problems. The code below was marked in very red colours. I have three of this type of code being used all the time. I think I should try and work out a more simple method. The other thing I did not understand or know if it is a problem was the following list:-

    Failed to load symbols for C:\WINDOWS\System32\ntdll.dll

    Failed to load symbols for C:\WINDOWS\System32\kernel32.dll

    Failed to load symbols for C:\WINDOWS\System32\SHCore.dll

    Failed to load symbols for C:\WINDOWS\System32\twinapi.appcore.dll

    Failed to load symbols for C:\WINDOWS\System32\combase.dll

    Failed to load symbols for C:\WINDOWS\System32\actxprxy.dll

    Failed to load symbols for C:\WINDOWS\System32\rpcrt4.dll

    Failed to load symbols for C:\WINDOWS\System32\Windows.UI.Xaml.dll

    Failed to load symbols for C:\WINDOWS\System32\user32.dll

    Failed to load symbols for C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll

    Loaded symbols for C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\Windows.UI.Xaml\f2bf020fc6307e10194fd94e85d52a72\Windows.UI.Xaml.ni.dll

    Failed to load symbols for C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clrjit.dll

    Loaded symbols for C:\Users\Malc\Desktop\CR30414\CR30414\CR20414\CR17414\Contract_Rummy\bin\Debug\AppX\Contract_Rummy.exe

    Failed to load symbols for C:\WINDOWS\System32\KernelBase.dll

    Failed to load symbols for C:\WINDOWS\System32\MrmCoreR.dll

    Failed to load symbols for C:\WINDOWS\System32\BCP47Langs.dll

    Failed to load symbols for C:\WINDOWS\System32\Windows.UI.dll

    Failed to load symbols for C:\WINDOWS\System32\imm32.dll

    Failed to load symbols for C:\WINDOWS\System32\msctf.dll

    Loaded symbols for C:\Windows\assembly\NativeImages_v4.0.30319_32\Windows.Gloaae92e31#\a1306b1fdd9c22508f9e5d901fceb4cd\Windows.Globalization.ni.dll

    Loaded symbols for C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\mscorlib\c90ef9a73ea0044641d31b19023aad61\mscorlib.ni.dll

    Loaded symbols for C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\System\c24d08cc4e93fc4f6f15a637b00a2721\System.ni.dll

    Failed to load symbols for C:\WINDOWS\System32\msftedit.dll

    Failed to load symbols for C:\WINDOWS\System32\gdi32.dll

    Failed to load symbols for C:\WINDOWS\System32\DWrite.dll

    Failed to load symbols for C:\WINDOWS\System32\Windows.Globalization.dll

    Failed to load symbols for C:\WINDOWS\System32\WinTypes.dll

    Loaded symbols for C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\Windows.Storage\f3deb382d1f91df4e2bf1801afb4ea21\Windows.Storage.ni.dll

    Failed to load symbols for C:\WINDOWS\System32\Windows.Storage.ApplicationData.dll

    Loaded symbols for C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\Microsoft.V9921e851#\288e4f2cf5b7a96028c8bb3fce6dc043\Microsoft.VisualBasic.ni.dll

    Loaded symbols for C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\System.Runt0d283adf#\32aee6654d81a07e698f9ee18c886a2a\System.Runtime.WindowsRuntime.ni.dll

    Loaded symbols for C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\Windows.App640a3541#\224ab0385dc2991b9139bdbf7bcf8e0e\Windows.ApplicationModel.ni.dll

    Failed to load symbols for C:\WINDOWS\System32\msvcr120_clr0400.dll

    Failed to load symbols for C:\WINDOWS\System32\uxtheme.dll

    Failed to load symbols for C:\WINDOWS\System32\dcomp.dll

    Failed to load symbols for C:\WINDOWS\System32\msvcrt.dll

    Failed to load symbols for C:\WINDOWS\System32\d2d1.dll

    Failed to load symbols for C:\WINDOWS\System32\d3d11.dll

    Failed to load symbols for C:\Windows\System32\atiuxpag.dll

    Failed to load symbols for C:\Windows\System32\atidxx32.dll

    Failed to load symbols for C:\WINDOWS\System32\WindowsCodecs.dll

    Failed to load symbols for C:\WINDOWS\System32\dxgi.dll

    Failed to load symbols for C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll

    Loaded symbols for C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\Windows.UI\c95c4deae76420a882bef7161a449d72\Windows.UI.ni.dll

    Failed to load symbols for C:\WINDOWS\System32\urlmon.dll

    Failed to load symbols for C:\WINDOWS\System32\iertutil.dll

    Failed to load symbols for C:\WINDOWS\System32\ninput.dll

    Failed to load symbols for C:\Windows\System32\aticfx32.dll

    Failed to load symbols for C:\WINDOWS\System32\MFMediaEngine.dll

    Failed to load symbols for C:\WINDOWS\System32\RTWorkQ.dll

    Failed to load symbols for C:\WINDOWS\System32\Windows.Media.MediaControl.dll

    Failed to load symbols for C:\WINDOWS\System32\sechost.dll

    Failed to load symbols for C:\WINDOWS\System32\mfplat.dll

    Failed to load symbols for C:\WINDOWS\System32\mfcore.dll

    Failed to load symbols for C:\WINDOWS\System32\mfsrcsnk.dll

    Failed to load symbols for C:\WINDOWS\System32\MMDevAPI.dll

    Failed to load symbols for C:\WINDOWS\System32\devobj.dll

    Failed to load symbols for C:\WINDOWS\System32\cfgmgr32.dll

    Failed to load symbols for C:\WINDOWS\System32\AudioSes.dll

    Failed to load symbols for C:\WINDOWS\System32\RESAMPLEDMO.DLL

    Failed to load symbols for C:\WINDOWS\System32\wininet.dll

    Failed to load symbols for C:\WINDOWS\System32\oleaut32.dll

    Loaded symbols for C:\WINDOWS\assembly\NativeImages_v4.0.30319_32\System.Runtc259d85b#\ed68489987b413410ccb94c6e704f6b4\System.Runtime.WindowsRuntime.UI.Xaml.ni.dll

    Failed to load symbols for C:\WINDOWS\System32\Windows.UI.Immersive.dll

    Failed to load symbols for C:\WINDOWS\System32\dui70.dll

    Failed to load symbols for C:\WINDOWS\System32\duser.dll

    Failed to load symbols for C:\WINDOWS\System32\UIAnimation.dll

    Failed to load symbols for C:\WINDOWS\System32\d3d10warp.dll

    Failed to load symbols for C:\WINDOWS\System32\slc.dll

    Failed to load symbols for C:\WINDOWS\System32\dwmapi.dll

    Symbol information saved to report.

    The code is exactly what I used in VS 2012 for desktop and it worked fine but I think perhaps store apps are more sensitive to memory problems?

    Thanks

    Malcolm

    Private Async Function CheckNextInRun(i As Integer, TheSuit As Integer) As Task(Of Integer)
            For x As Integer = 1 To Hand.GetUpperBound(0)
                'Check that it is not already in a run no need  check for sets as not   done until after runs
                If Cards(Hand(x).CN).InRun = False Then
                    If Hand(x).Value = Hand(i).Value + 1 Then
                        If Hand(x).Suit = TheSuit Then ' joker should never equal the suit
                            Return x
                        End If
                    End If
                End If
            Next x
            Return 0
            Await Task.Delay(5)
        End Function
        Private Async Function CheckRunOne(Who As Players) As Task  ' will be for  on of three max  runs
            If HandWon = True Or GameWon = True Then Exit Function
            Dim intNext As Integer
            Dim intCount As Integer
            Dim FirstCard As Integer
            Dim i As Integer
            Dim x As Integer
            i = 1
            Do Until i = Hand.GetUpperBound(0) + 1
                intNext = Await CheckNextInRun(i, Hand(i).Suit)
                If intNext > 0 Then
                    If FirstCard = 0 Then FirstCard = i
                    i = intNext
                    intCount = intCount + 1
                Else
                    If intCount >= 3 Then  'looking for run of four
                        FCard(Who, 1) = Hand(FirstCard).CN
                        For x = 1 To Hand.GetUpperBound(0)
                            If Hand(x).CN <> FCard(Who, 1) Then
                                If Hand(x).Value = Hand(FirstCard).Value + 1 And Hand(x).Suit _
                                    = Hand(FirstCard).Suit Then
                                    SCard(Who, 1) = Hand(x).CN
                                ElseIf Hand(x).Value = Hand(FirstCard).Value + 2 And Hand(x).Suit _
                                    = Hand(FirstCard).Suit Then
                                    TCard(Who, 1) = Hand(x).CN
                                ElseIf Hand(x).Value = Hand(FirstCard).Value + 3 And Hand(x).Suit _
                                    = Hand(FirstCard).Suit Then
                                    LCard(Who, 1) = Hand(x).CN
                                    Exit For
                                End If
                            End If
                        Next x
                        Cards(FCard(Who, 1)).NoDiscardPerm = True
                        Cards(SCard(Who, 1)).NoDiscardPerm = True
                        Cards(TCard(Who, 1)).NoDiscardPerm = True
                        Cards(LCard(Who, 1)).NoDiscardPerm = True
                        Cards(FCard(Who, 1)).InRun = True
                        Cards(SCard(Who, 1)).InRun = True
                        Cards(TCard(Who, 1)).InRun = True
                        Cards(LCard(Who, 1)).InRun = True
                        HasRun(Who, 1) = True
                        Exit Function
                        FCard(Who, 1) = 0
                        SCard(Who, 1) = 0
                        TCard(Who, 1) = 0
                        LCard(Who, 1) = 0
                        FirstCard = 0
                        intCount = 0
                        'Exit Do
                    End If
                    FCard(Who, 1) = 0
                    SCard(Who, 1) = 0
                    TCard(Who, 1) = 0
                    LCard(Who, 1) = 0
                    FirstCard = 0
                    intCount = 0
                    i = i + 1
                End If
            Loop
        End Function
    



    Malcolm Bain

    Tuesday, May 13, 2014 5:13 PM
  • Hi Malcolm,
           Did you actually generate a memory dump of the problem when it occurred?  If so, please post it to a OneDrive share and we can take a look at it.

         From the description, I would say that you are running into a hang condition rather than a memory condition.  The memory dump will capture a list of the callstacks at the time of the hang and then we can try to determine where the problem lies.


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Tuesday, May 13, 2014 7:20 PM
    Moderator
  • Hi Matt,

    Very sorry, but I think I am getting out of my depth-I'm very much an amateur. I have no idea how to generate a memory dump and when it hangs I have to close the program and VS has also shut down. Some of the help urls you gave me early now appear with 'sorry, no longer available.

    The debugging diagnostics does show loops in red from which I assume it is these causing the hanging. The debugging diagnostics is 356 MB. I did upload it to One Drive but then it said I could not share and in any case feel this is not what you want.

    I think perhaps I should just try to rewrite trying to find a way of coding that does not involve so many long loops?

    Would you agree that might solve the problem?

    Thank you

    Malcolm

    PS It is such a pity because apart from the hanging it all works perfectly until a hang up


    Malcolm Bain

    Wednesday, May 14, 2014 6:45 AM
  • I recommend that you open a support case at this time.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, May 15, 2014 7:10 PM
    Moderator