Skip to content

Instantly share code, notes, and snippets.

@avalanche123
Created April 3, 2012 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avalanche123/56af0497b248446b2cf5 to your computer and use it in GitHub Desktop.
Save avalanche123/56af0497b248446b2cf5 to your computer and use it in GitHub Desktop.
# include <uv.h>
# include <stdio.h>
static int count = 0;
void close_cb(uv_handle_t* handle)
{
// free(handle);
}
void timer_cb(uv_timer_t* timer, int status)
{
puts("1");
if (count >= 10) {
uv_unref(uv_default_loop());
// uv_timer_stop(timer);
uv_close((uv_handle_t*)timer, close_cb);
}
count++;
}
int main(int argc, char* argv[])
{
uv_timer_t timer;
uv_timer_init(uv_default_loop(), &timer);
uv_timer_start(&timer, timer_cb, 1, 1);
uv_run(uv_default_loop());
uv_loop_delete(uv_default_loop());
}
Bulat-Shakirzyanovs-MacBook-Air:examples bulatshakirzyanov$ valgrind ./example
==3028== Memcheck, a memory error detector
==3028== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==3028== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==3028== Command: ./example
==3028==
--3028-- ./example:
--3028-- dSYM directory is missing; consider using --dsymutil=yes
1
1
1
1
1
1
1
1
1
1
1
==3028==
==3028== Process terminating with default action of signal 6 (SIGABRT)
==3028== at 0x170E82A: __kill (in /usr/lib/system/libsystem_kernel.dylib)
==3028== by 0x23179: ev_unref (in /usr/local/Cellar/libuv/HEAD/lib/uv.1.dylib)
==3028== by 0x227C2: ev_invoke_pending (in /usr/local/Cellar/libuv/HEAD/lib/uv.1.dylib)
==3028== by 0x266FB: ev_run (in /usr/local/Cellar/libuv/HEAD/lib/uv.1.dylib)
==3028== by 0x19CB7: uv_run (in /usr/local/Cellar/libuv/HEAD/lib/uv.1.dylib)
==3028== by 0x100000C11: main (in ./example)
==3028==
==3028== HEAP SUMMARY:
==3028== in use at exit: 234,278 bytes in 990 blocks
==3028== total heap usage: 1,523 allocs, 533 frees, 311,966 bytes allocated
==3028==
==3028== LEAK SUMMARY:
==3028== definitely lost: 0 bytes in 0 blocks
==3028== indirectly lost: 0 bytes in 0 blocks
==3028== possibly lost: 0 bytes in 0 blocks
==3028== still reachable: 234,278 bytes in 990 blocks
==3028== suppressed: 0 bytes in 0 blocks
==3028== Rerun with --leak-check=full to see details of leaked memory
==3028==
==3028== For counts of detected and suppressed errors, rerun with: -v
==3028== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 116 from 8)
Abort trap: 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment