Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27083

VS 2012 Threading and OutOfMemory Exception?

$
0
0
Hello, I'd consider myself new to threading and I fear I am giving my GarbageCollector too much work :p

I have a list (currently ~10 items). When the user pushes the Start button, it needs to call the DoProcess sub, passing each item as a parameter.

Currently I have:
Code:

  For x As Integer = 0 To items.Count - 1
            Dim index As Integer = x
            ThreadPool.QueueUserWorkItem(Sub() DoProcess(items.(index)))
        Next

Now, the DoProcess sub runs recursively.. that is:
Code:

Sub DoProcess(item As String)
    'does some processes...
    DoProcess(item)

The program works perfectly until ~2/3 hours in, it will crash with an OutOfMemory Exception thrown.

Do I need to be disposing of my threads? Any advice would be great at this point, I'm running out of ideas.

Viewing all articles
Browse latest Browse all 27083


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>