On Tuesday, July 1, 2014 1:56:03 PM UTC+5:30, Saúl Ibarra Corretgé wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 07/01/2014 10:22 AM, Ashish wrote:
> >
> >
> > On Tuesday, July 1, 2014 1:44:56 PM UTC+5:30, Saúl Ibarra Corretgé
> > wrote:
> >
> > On 07/01/2014 09:44 AM, Ashish wrote:
> >
> >> I am using libuv in console based application being developed on
> >> Windows XP When my applications memory usage goes high, at
> >> certain point (at around 2GB) uv_queue_work crashes with "runtime
> >> error" and sometimes with "R6016- not enough space for thread
> >> data"
> >
> >
> >> This little piece of code demonstrates the same. The code below
> >> tries to create 321 threads. (I am using 321 number for demo
> >> purpose but in original code the number is just 31) 321 is not
> >> high number of threads on Windows XP. Still why would it crash:
> >
> >
> >> void work_in_thread(uv_work_t* work_t) { // Allocate some memory
> >> char* memory = new (std::nothrow) char[4321];
> >
> >> // Simulate some delay Sleep(3); }
> >
> >> void after_work_in_thread(uv_work_t* work_t, int status) { //
> >> Recreate just ended thread (to maintain thread count) int RetVal
> >> = uv_queue_work(loop, work_t, work_in_thread,
> >> after_work_in_thread); if (RetVal != 0) printf("\nERROR
> >> recreating thread"); }
> >
> >> int main() { loop = uv_default_loop();
> >
> >> // Create working threads for (int i=0; i<321; i++) { uv_work_t*
> >> work_t; work_t = (uv_work_t*) malloc(sizeof(uv_work_t)); int
> >> RetVal = uv_queue_work(loop, work_t, work_in_thread,
> >> after_work_in_thread); if (RetVal != 0) printf("\nERROR creating
> >> thread"); }
> >
> >> uv_run(loop, UV_RUN_DEFAULT);
> >
> >> printf ("\nCame out of loop...");
> >
> >> return 0; }
> >
> >
> > uv_queue_work doesn't do what you think it does. It does not create
> > a new thread each time you call it, it calls the given function on
> > the internal threadpool, which has size 4.
> >
> > On top of that, you are reusing the uv_work_t request in the
> > after_work_cb, and I think there was a bug in there. Can you try
> > this patch? https://gist.github.com/saghul/62da49b306618db381c7
> > <https://gist.github.com/saghul/62da49b306618db381c7> (make sure
> > you are using latest master)
> >
> >
> >
> > Hi,
> >
> > yes I am aware it is threadpool of size 4 but so far till now it
> > works perfectly as per my expectation (except this crash at 2GB).
> >
>
> Well, not really. I unified the threadpools a few days ago, before
> that we used QueueUserWorkItem Windows API which basically creates a
> new thread each time, IIRC.
>
>
Well yes I am using exactly same libuv (and that's what its expected here
in my app)
Can we not fix it with having QueueUserWorkItem ?
- --
> Saúl Ibarra Corretgé
> bettercallsaghul.com
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1
> Comment: Using GnuPG with Icedove - http://www.enigmail.net/
>
> iQIcBAEBAgAGBQJTsnBcAAoJEEEOVVOum8BZ5XcP/ieK8OthQy3D5llSJuHscMLP
> TM5ED+sirHjCPPJd7ZjtXw/X9WjPRu6KeDu5Pr3aq0uYrBnOXRg6Agl5oz/sA0Pl
> gjYCHga8MrhvyhV6jIyf/hygMfPHS9CWt2E2JPnTFDqSz0Zxh7hInnpGcNj2NjbQ
> nSAmVSnBoEz07oqlNcto3Y2KxxmiwSypEiOUCXdtC/3xBooB8A5uQNhveNpxtL5p
> 8PWsRcDYu4PlrlqVOsvMZxEvUVsuZig9Ngf5dAZIpS6hXGUAOm+i2Jzm604J3/0P
> hspRlrSZouLCz180IjeedzhON/W7MnKoiHy3Fbzi89w09EWHhsDbTmjxvzLDzhi5
> AdN+IbNsUmaY3QXKl3qrCN3vC1Bb+aM2o9rL6ozc1PvtCpVK9TdkDG8XwXr7H7u+
> iCF96RaiFm5TEir1omomjsxXIYZrGkjpp4ucWSSVlVxXFhKg1SG+87tYN79qksL5
> cm9jN7EDYumhS6qIysbkVYr3OJwzl/3WKQ0GJuFdf9IkkCZpPOQsy8hifaruLeVB
> NqtzHEWZDCLVKrvmYzCQBjWulfWcJPeJi+dS6ijE6W5p938NwtMogYI7k2rpPWtG
> MfTy1aEv8CSBdDzwscPeqK0TSbmBJk3veMDaowTmNn6Lhkx3HUTH0092R9gGP3YU
> cK2wPiegufghywg8brVI
> =6h6Z
> -----END PGP SIGNATURE-----
>
--
You received this message because you are subscribed to the Google Groups
"libuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/d/optout.