I am not sure ... but i get confused about that:
and I did not know a way to store handles to a dynamically changing number of threads
|
Is that not possible? I think you can use a vector or a map to store the handles ... that would work easily with a map i think.
Also, i am not sure, if an access violation should be the result of using too much memory ...
you can see memory usage in the task-manager, so you determine if the application really consumes all your RAM.
In addition, if that happens, some allocation will fail, and i would bet for a "malloc" that fails because of "NO MEMORY", just returning NULL ("new" throws exceptions ...) or something simmilar ... don't know, maybe you should handle that out_of_memory case in your code and terminate the application if such a thing happend ...
Mybe you don't use "malloc" fcns ... then i have no idea, how an access violation can happen ... it should be some "bad_alloc" exception or, well ... i don't know.
Hope that helps you,
,....