On Tuesday, July 1, 2014 1:44:56 PM UTC+5:30, Saúl Ibarra Corretgé wrote:
>
> -----BEGIN PGP SIGNED MESSAGE----- 
> Hash: SHA1 
>
> 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 (make sure 
> you are using latest master) 
>
> - -- 
> Saúl Ibarra Corretgé 
> bettercallsaghul.com 
>
> -----BEGIN PGP SIGNATURE----- 
> Version: GnuPG v1 
> Comment: Using GnuPG with Icedove - http://www.enigmail.net/ 
>
> iQIcBAEBAgAGBQJTsm3BAAoJEEEOVVOum8BZ6T8QAL6Y8nqFLsqR0SEN7Eg9D2bU 
> Q1E93oTe1VfGWlSDsttfgOASkl9uFKJmOnMR/uuLS14k+yVtCYB64xaSpTzBeKzp 
> dbg9TtFzGKsIVOUDS/Mhp2oDgnDRGU5UeyomHDpjwxoi93FYwayq8iabkjYA/eTB 
> bFeyu4O6emyKSNWILRAduOJNqOxfMy7sKE/CJDAchddTVLb3Ca8yzzIIrgtskDU/ 
> pqmg6r4h8MKMGPwhGtqMAe1fzhABQPDObLPrnaj7RZZFLLmKSv5xUMS/NU0rJrdJ 
> aGFKdtkilEhqLkgITI8Yay2U1TzoT0pI7z7SpvPpK+/VwSD8z1yyBL3Wn4DYe/v2 
> WJtHqRb/K65KfMSdr3IizNyNtcFZggy031UZrQJudFQgxo9/4hSlKY3MiPrE32kD 
> LaT1jtTdju1VI+6sKYATNc68pss24JSBV4OPgFdfTdu2S5AXy5BnlPURAZZCyYU5 
> o4v7AV5mK6u83dGV5ytBTq7gDGw6rXK2eqdeqzGjxohyh4R0HxnLzYyuOgNYPtSl 
> tp0k1dUPrnhcnwmmyrxp8iIhDu5WgaSzjjBSj+GVfkn6ZZstaa2lMGa6Dxf/JEqQ 
> jQFXeH4nQTIc4veZpwjMt8g9tZqIlnvuI67yTSd2cvt3snbkKj5tOPFx2z9kZ6cv 
> bTC6XwCl1UmJLvyxXK4t 
> =fQlG 
> -----END PGP SIGNATURE----- 
>

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). 

work_t once allocated remains same otherwise it would have crashed much 
earlier.
However I'll try the patch and will let you know.

Many thanks,
Ashish

-- 
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 libuv+unsubscr...@googlegroups.com.
To post to this group, send email to libuv@googlegroups.com.
Visit this group at http://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/d/optout.

Reply via email to