Sponsored Content
Top Forums UNIX for Advanced & Expert Users Memory leak while using pthread_cancel() Post 302315431 by kcr on Tuesday 12th of May 2009 09:51:21 AM
Old 05-12-2009
I compiled and executed it as a C program. but the result is still worse.

Valgrind Output:
==19464== Memcheck, a memory error detector.
==19464== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==19464== Using LibVEX rev 1732, a library for dynamic binary translation.
==19464== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==19464== Using valgrind-3.2.3, a dynamic binary instrumentation framework.
==19464== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==19464== For more details, rerun with: -v
==19464==
Iam child process
Main thread cancelling the child
waiting for child
main thread exiting
bye ==19464==
==19464== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 17 from 1)
==19464== malloc/free: in use at exit: 908 bytes in 5 blocks.
==19464== malloc/free: 6 allocs, 1 frees, 1,044 bytes allocated.
==19464== For counts of detected errors, rerun with: -v
==19464== searching for pointers to 5 not-freed blocks.
==19464== checked 64,144 bytes.
==19464==
==19464== 19 bytes in 1 blocks are still reachable in loss record 1 of 5
==19464== at 0x4022525: malloc (vg_replace_malloc.c:149)
==19464== by 0x400AB37: _dl_new_object (in /lib/ld-2.7.so)
==19464== by 0x40060D0: _dl_map_object_from_fd (in /lib/ld-2.7.so)
==19464== by 0x40084FB: _dl_map_object (in /lib/ld-2.7.so)
==19464== by 0x4011E70: dl_open_worker (in /lib/ld-2.7.so)
==19464== by 0x400E1B5: _dl_catch_error (in /lib/ld-2.7.so)
==19464== by 0x4011851: _dl_open (in /lib/ld-2.7.so)
==19464== by 0x41645D1: do_dlopen (in /lib/libc-2.7.so)
==19464== by 0x400E1B5: _dl_catch_error (in /lib/ld-2.7.so)
==19464== by 0x4164784: __libc_dlopen_mode (in /lib/libc-2.7.so)
==19464== by 0x404F206: pthread_cancel_init (in /lib/libpthread-2.7.so)
==19464== by 0x404B648: pthread_cancel (in /lib/libpthread-2.7.so)
==19464==
==19464==
==19464== 19 bytes in 1 blocks are still reachable in loss record 2 of 5
==19464== at 0x4022525: malloc (vg_replace_malloc.c:149)
==19464== by 0x4008A47: _dl_map_object (in /lib/ld-2.7.so)
==19464== by 0x4011E70: dl_open_worker (in /lib/ld-2.7.so)
==19464== by 0x400E1B5: _dl_catch_error (in /lib/ld-2.7.so)
==19464== by 0x4011851: _dl_open (in /lib/ld-2.7.so)
==19464== by 0x41645D1: do_dlopen (in /lib/libc-2.7.so)
==19464== by 0x400E1B5: _dl_catch_error (in /lib/ld-2.7.so)
==19464== by 0x4164784: __libc_dlopen_mode (in /lib/libc-2.7.so)
==19464== by 0x404F206: pthread_cancel_init (in /lib/libpthread-2.7.so)
==19464== by 0x404B648: pthread_cancel (in /lib/libpthread-2.7.so)
==19464== by 0x80485F4: main (testc.c:20)
==19464==
==19464==
==19464== 28 bytes in 1 blocks are still reachable in loss record 3 of 5
==19464== at 0x4022525: malloc (vg_replace_malloc.c:149)
==19464== by 0x400CDD2: _dl_map_object_deps (in /lib/ld-2.7.so)
==19464== by 0x4011ECC: dl_open_worker (in /lib/ld-2.7.so)
==19464== by 0x400E1B5: _dl_catch_error (in /lib/ld-2.7.so)
==19464== by 0x4011851: _dl_open (in /lib/ld-2.7.so)
==19464== by 0x41645D1: do_dlopen (in /lib/libc-2.7.so)
==19464== by 0x400E1B5: _dl_catch_error (in /lib/ld-2.7.so)
==19464== by 0x4164784: __libc_dlopen_mode (in /lib/libc-2.7.so)
==19464== by 0x404F206: pthread_cancel_init (in /lib/libpthread-2.7.so)
==19464== by 0x404B648: pthread_cancel (in /lib/libpthread-2.7.so)
==19464== by 0x80485F4: main (testc.c:20)
==19464==
==19464==
==19464== 224 bytes in 1 blocks are still reachable in loss record 4 of 5
==19464== at 0x4021864: calloc (vg_replace_malloc.c:279)
==19464== by 0x400F963: _dl_check_map_versions (in /lib/ld-2.7.so)
==19464== by 0x40121A0: dl_open_worker (in /lib/ld-2.7.so)
==19464== by 0x400E1B5: _dl_catch_error (in /lib/ld-2.7.so)
==19464== by 0x4011851: _dl_open (in /lib/ld-2.7.so)
==19464== by 0x41645D1: do_dlopen (in /lib/libc-2.7.so)
==19464== by 0x400E1B5: _dl_catch_error (in /lib/ld-2.7.so)
==19464== by 0x4164784: __libc_dlopen_mode (in /lib/libc-2.7.so)
==19464== by 0x404F206: pthread_cancel_init (in /lib/libpthread-2.7.so)
==19464== by 0x404B648: pthread_cancel (in /lib/libpthread-2.7.so)
==19464== by 0x80485F4: main (testc.c:20)
==19464==
==19464==
==19464== 618 bytes in 1 blocks are still reachable in loss record 5 of 5
==19464== at 0x4021864: calloc (vg_replace_malloc.c:279)
==19464== by 0x400A8CA: _dl_new_object (in /lib/ld-2.7.so)
==19464== by 0x40060D0: _dl_map_object_from_fd (in /lib/ld-2.7.so)
==19464== by 0x40084FB: _dl_map_object (in /lib/ld-2.7.so)
==19464== by 0x4011E70: dl_open_worker (in /lib/ld-2.7.so)
==19464== by 0x400E1B5: _dl_catch_error (in /lib/ld-2.7.so)
==19464== by 0x4011851: _dl_open (in /lib/ld-2.7.so)
==19464== by 0x41645D1: do_dlopen (in /lib/libc-2.7.so)
==19464== by 0x400E1B5: _dl_catch_error (in /lib/ld-2.7.so)
==19464== by 0x4164784: __libc_dlopen_mode (in /lib/libc-2.7.so)
==19464== by 0x404F206: pthread_cancel_init (in /lib/libpthread-2.7.so)
==19464== by 0x404B648: pthread_cancel (in /lib/libpthread-2.7.so)
==19464==
==19464== LEAK SUMMARY:
==19464== definitely lost: 0 bytes in 0 blocks.
==19464== possibly lost: 0 bytes in 0 blocks.
==19464== still reachable: 908 bytes in 5 blocks.
==19464== suppressed: 0 bytes in 0 blocks.
 

9 More Discussions You Might Find Interesting

1. Programming

about virtual memory and memory leak

Hi, First of all I appreciate this group very much for its informative discussions and posts. Here is my question. I have one process whose virtual memory size increases linearly from 6MB to 12MB in 20 minutes. Does that mean my process has memory leaks? In what cases does the... (4 Replies)
Discussion started by: shriashishpatil
4 Replies

2. Programming

Memory leak of fork()

Today, I wrote a test code for fork/execvp/waitpid. In the parent process, it fork 100 child processes which only execute "date" to print the current datetime. When any child process die, the parent process will receive a SIGCHLD signal. Then, the parent process will re-fork-execvp the child... (7 Replies)
Discussion started by: whererush
7 Replies

3. Programming

Memory LEAK with pthreads

I have this code... #include <stdio.h> #include <iostream> #include <pthread.h> static void* cliente(void *datos); int main() { pthread_attr_t tattr; int ret; size_t size = PTHREAD_STACK_MIN + 0x0100; ret = pthread_attr_init(&tattr); ret =... (8 Replies)
Discussion started by: JEscola
8 Replies

4. UNIX for Advanced & Expert Users

Memory leak in pthread

helo frnds, I am using RHEL5 and C lang for development. I am getting some memory leak problem in pthread. I hav developed a program which creates two threads for listening purpose on two diff ports. both the child threads are doing same job but on diff port no. I am using... (4 Replies)
Discussion started by: mindTeaser
4 Replies

5. IP Networking

memory leak?

Hi All, my client server application can work in two modes: 1) one direction - only client sends msgs to server 2) two directions - server gives 'answers' to client. when program run in the first mode it looks OK, but when server answers to client than client's application exit its... (2 Replies)
Discussion started by: lenna
2 Replies

6. Programming

memory leak problem

hi all Can any one plz explain me about memory leak problem Thankx (5 Replies)
Discussion started by: sonali
5 Replies

7. Programming

Memory Leak

Hi, I am trying a database server which keeps a B+ plus tree structure and works on it. I am trying to find the memory used/leak while executing this process. I check the memory leak by using ps uax command. When i execute a delete query i am sure that my code frees up the existing... (9 Replies)
Discussion started by: kumaran_5555
9 Replies

8. Red Hat

Memory leak

Hi all I am using RED HAT 5.4, and i am getting memory uses problem. when i use "sync;echo 3 > /proc/sys/vm/drop_cache" command the memory will release after 2,3 hour memory show 95%. pls suggest right way. thanks (37 Replies)
Discussion started by: reply.ravi
37 Replies

9. Web Development

Finding Cause of Memory Leak

Hi We have just got a dedicated server with Fasthosts, O/S is Linux CentOS 6 64 bit. It was a fresh install and I have just moved one WordPress site onto there. The problem is we seem to be getting a memory leak (that's what Fasthosts said) and the database (I think) keeps crashing, so we... (3 Replies)
Discussion started by: Pokeyzx
3 Replies
All times are GMT -4. The time now is 01:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy