c - Valgrind memory leak points to localtime -


i have code:

#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/time.h> #include <sys/resource.h>  double get_time() {     struct timeval t;     struct timezone tzp;     gettimeofday(&t, &tzp);     return t.tv_sec + t.tv_usec*1e-6; }  #define ll_append(what, where, type) { \     what->next = null; \     what->prev = null; \     if(!where) { \         = what; \     } else { \         type current = where; \         while(current->next != null) \             current = current->next; \         current->next = what; \         what->prev = current; \     } \ }  struct edge {     struct node *from;     struct node *to;     char *label; };  struct edge_list {     struct edge *edge;     struct edge_list *prev;     struct edge_list *next; };  struct graph {     struct node_list *nodes;     struct edge_list *edges;     int nodes_count;     int edges_count; };  struct node {     char *name;     struct edge_list *in;     struct edge_list *out;     struct graph *graph; };  struct node_list {     struct node *node;     struct node_list *prev;     struct node_list *next; };  struct graph *graph_create_empty() {     struct graph *graph = malloc(sizeof(struct graph));      graph->nodes = null;     graph->edges = null;     graph->nodes_count = 0;     graph->edges_count = 0;      return graph; }   void edge_destroy(struct edge *edge) {     free(edge->label);     free(edge); }   void node_destroy(struct node *node) {     struct edge_list *tmp_edge, *edge;      edge = node->in;     while(edge != null) {         tmp_edge = edge;         edge     = edge->next;         free(tmp_edge);     }      edge = node->out;     while(edge != null) {         tmp_edge = edge;         edge     = edge->next;         free(tmp_edge);     }      free(node->name);     free(node); }  void graph_destroy(struct graph *graph) {     struct edge_list *tmp_edge, *edge;     edge = graph->edges;     while(edge != null) {         tmp_edge = edge;         edge     = edge->next;         edge_destroy(tmp_edge->edge);         free(tmp_edge);     }      struct node_list *tmp_node, *node;     node = graph->nodes;     while(node != null) {         tmp_node = node;         node     = node->next;         node_destroy(tmp_node->node);         free(tmp_node);     }      free(graph); }   void graph_add_edge(struct graph *graph, struct edge *edge) {     struct edge_list *new_edge = malloc(sizeof(struct edge_list));     new_edge->edge = edge;      ll_append(new_edge, graph->edges, struct edge_list *);     graph->edges_count++; }  void graph_add_node(struct graph *graph, struct node *node) {     node->graph = graph;      struct node_list *new_node = malloc(sizeof(struct node_list));     new_node->node = node;      ll_append(new_node, graph->nodes, struct node_list *);     graph->nodes_count++; }  struct node *node_create(const char *name, struct graph *graph) {     struct node *node = malloc(sizeof(struct node));      node->name = malloc(strlen(name)+1);     strcpy(node->name, name);      node->in  = null;     node->out = null;      if(graph)         graph_add_node(graph, node);      return node; }  void node_add_edge(struct node *node, struct edge *edge) {     struct edge_list *new_edge = malloc(sizeof(struct edge_list));      if(node == edge->to) {         ll_append(new_edge, node->out, struct edge_list *);     } else {         ll_append(new_edge, node->in, struct edge_list *);     } }  void node_connect(const char *label, struct node *from, struct node *to) {     if(from->graph != to->graph || from->graph == null)          return;      struct edge *edge = malloc(sizeof(struct edge));      edge->label = malloc(strlen(label)+1);     strcpy(edge->label, label);      edge->from = from;     edge->to   = to;      graph_add_edge(from->graph, edge);     node_add_edge(from,         edge);     node_add_edge(to,           edge); }  int main(int argc, char *argv[]) {     double start = get_time();      for(int = 0; < 100000; i++) {         struct graph *graph = graph_create_empty();          // create nodes         struct node *useful_demand_heat = node_create("useful_demand_heat", graph);         struct node *useful_demand_elec = node_create("useful_demand_elec", graph);          struct node *space_heater_coal  = node_create("space_heater_coal", graph);         struct node *space_heater_gas   = node_create("space_heater_gas", graph);         struct node *space_heater_oil   = node_create("space_heater_oil", graph);         struct node *space_heater_chp   = node_create("space_heater_chp", graph);         struct node *space_heater_elec  = node_create("space_heater_elec", graph);          struct node *final_demand_coal  = node_create("final_demand_coal", graph);         struct node *final_demand_gas  = node_create("final_demand_gas", graph);         struct node *final_demand_oil  = node_create("final_demand_oil", graph);         struct node *final_demand_elec  = node_create("final_demand_elec", graph);          struct node *lv_network = node_create("lv_network", graph);         struct node *mv_network = node_create("mv_network", graph);         struct node *hv_network = node_create("hv_network", graph);          struct node *coal_plant = node_create("coal_plant", graph);         struct node *elec_import = node_create("elec_import", graph);          // edges         node_connect("electricity", elec_import, hv_network);         node_connect("electricity", coal_plant, hv_network);          node_connect("electricity", hv_network, mv_network);         node_connect("electricity", mv_network, lv_network);         node_connect("electricity", lv_network, final_demand_elec);          node_connect("electricity", final_demand_elec, space_heater_elec);         node_connect("coal", final_demand_coal, space_heater_coal);         node_connect("gas", final_demand_gas, space_heater_gas);         node_connect("gas", final_demand_gas, space_heater_chp);         node_connect("oil", final_demand_oil, space_heater_oil);          node_connect("heat", space_heater_coal, useful_demand_heat);         node_connect("heat", space_heater_gas, useful_demand_heat);         node_connect("heat", space_heater_oil, useful_demand_heat);         node_connect("heat", space_heater_chp, useful_demand_heat);          node_connect("electricity", space_heater_chp, useful_demand_elec);         node_connect("electricity", space_heater_elec, useful_demand_elec);         graph_destroy(graph);     }      double finish = get_time();     printf("took %.5f ms run\n", (finish - start)); } 

when run valgrind against it, these warnings:

==44508== memcheck, memory error detector ==44508== copyright (c) 2002-2012, , gnu gpl'd, julian seward et al. ==44508== using valgrind-3.8.1 , libvex; rerun -h copyright info ==44508== command: ./graph ==44508==  ==44508== warning: support on macos 10.8 experimental , broken. ==44508== warning: expect incorrect results, assertions , crashes. ==44508== warning: in particular, memcheck on 32-bit programs fail ==44508== warning: detect errors associated heap-allocated data. ==44508==  --44508-- ./graph: --44508-- dsym directory missing; consider using --dsymutil=yes took 22.74883 ms run done. ==44508==  ==44508== heap summary: ==44508==     in use @ exit: 74,666 bytes in 365 blocks ==44508==   total heap usage: 12,900,518 allocs, 12,900,153 frees, 284,078,620 bytes allocated ==44508==  ==44508== 16 bytes in 1 blocks lost in loss record 7 of 88 ==44508==    @ 0x54d7: malloc_zone_malloc (in /usr/local/cellar/valgrind/3.8.1/lib/valgrind/vgpreload_memcheck-amd64-darwin.so) ==44508==    0x373381: recursive_mutex_init (in /usr/lib/libobjc.a.dylib) ==44508==    0x372025: _objc_init (in /usr/lib/libobjc.a.dylib) ==44508==    0xbb27: libsystem_initializer (in /usr/lib/libsystem.b.dylib) ==44508==    0x7fff5fc13377: imageloadermacho::domodinitfunctions(imageloader::linkcontext const&) (in /usr/lib/dyld) ==44508==    0x7fff5fc13761: imageloadermacho::doinitialization(imageloader::linkcontext const&) (in /usr/lib/dyld) ==44508==    0x7fff5fc1006d: imageloader::recursiveinitialization(imageloader::linkcontext const&, unsigned int, imageloader::initializertiminglist&) (in /usr/lib/dyld) ==44508==    0x7fff5fc0ffc3: imageloader::recursiveinitialization(imageloader::linkcontext const&, unsigned int, imageloader::initializertiminglist&) (in /usr/lib/dyld) ==44508==    0x7fff5fc0feb9: imageloader::runinitializers(imageloader::linkcontext const&, imageloader::initializertiminglist&) (in /usr/lib/dyld) ==44508==    0x7fff5fc01f9d: dyld::initializemainexecutable() (in /usr/lib/dyld) ==44508==    0x7fff5fc05b03: dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) (in /usr/lib/dyld) ==44508==    0x7fff5fc01396: dyldbootstrap::start(macho_header const*, int, char const**, long, macho_header const*, unsigned long*) (in /usr/lib/dyld) ==44508==  ==44508== 32 bytes in 1 blocks possibly lost in loss record 24 of 88 ==44508==    @ 0x5a95: malloc_zone_calloc (in /usr/local/cellar/valgrind/3.8.1/lib/valgrind/vgpreload_memcheck-amd64-darwin.so) ==44508==    0x3756ea: nxhashinsert (in /usr/lib/libobjc.a.dylib) ==44508==    0x37546c: nxcreatehashtablefromzone (in /usr/lib/libobjc.a.dylib) ==44508==    0x374788: _read_images (in /usr/lib/libobjc.a.dylib) ==44508==    0x3739eb: map_images_nolock (in /usr/lib/libobjc.a.dylib) ==44508==    0x3734f3: map_images (in /usr/lib/libobjc.a.dylib) ==44508==    0x7fff5fc04936: dyld::notifybatchpartial(dyld_image_states, bool, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)) (in /usr/lib/dyld) ==44508==    0x7fff5fc0467c: dyld::registerimagestatebatchchangehandler(dyld_image_states, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)) (in /usr/lib/dyld) ==44508==    0x83ed9: dyld_register_image_state_change_handler (in /usr/lib/system/libdyld.dylib) ==44508==    0x37204c: _objc_init (in /usr/lib/libobjc.a.dylib) ==44508==    0xbb27: libsystem_initializer (in /usr/lib/libsystem.b.dylib) ==44508==    0x7fff5fc13377: imageloadermacho::domodinitfunctions(imageloader::linkcontext const&) (in /usr/lib/dyld) ==44508==  ==44508== 64 bytes in 2 blocks possibly lost in loss record 36 of 88 ==44508==    @ 0x5a95: malloc_zone_calloc (in /usr/local/cellar/valgrind/3.8.1/lib/valgrind/vgpreload_memcheck-amd64-darwin.so) ==44508==    0x3756ea: nxhashinsert (in /usr/lib/libobjc.a.dylib) ==44508==    0x385324: realizeclass(class_t*) (in /usr/lib/libobjc.a.dylib) ==44508==    0x374e9c: _read_images (in /usr/lib/libobjc.a.dylib) ==44508==    0x3739eb: map_images_nolock (in /usr/lib/libobjc.a.dylib) ==44508==    0x3734f3: map_images (in /usr/lib/libobjc.a.dylib) ==44508==    0x7fff5fc04936: dyld::notifybatchpartial(dyld_image_states, bool, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)) (in /usr/lib/dyld) ==44508==    0x7fff5fc0467c: dyld::registerimagestatebatchchangehandler(dyld_image_states, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)) (in /usr/lib/dyld) ==44508==    0x83ed9: dyld_register_image_state_change_handler (in /usr/lib/system/libdyld.dylib) ==44508==    0x37204c: _objc_init (in /usr/lib/libobjc.a.dylib) ==44508==    0xbb27: libsystem_initializer (in /usr/lib/libsystem.b.dylib) ==44508==    0x7fff5fc13377: imageloadermacho::domodinitfunctions(imageloader::linkcontext const&) (in /usr/lib/dyld) ==44508==  ==44508== 64 bytes in 2 blocks possibly lost in loss record 37 of 88 ==44508==    @ 0x5a95: malloc_zone_calloc (in /usr/local/cellar/valgrind/3.8.1/lib/valgrind/vgpreload_memcheck-amd64-darwin.so) ==44508==    0x3756ea: nxhashinsert (in /usr/lib/libobjc.a.dylib) ==44508==    0x3757f6: _nxhashrehashtocapacity (in /usr/lib/libobjc.a.dylib) ==44508==    0x375748: nxhashinsert (in /usr/lib/libobjc.a.dylib) ==44508==    0x385324: realizeclass(class_t*) (in /usr/lib/libobjc.a.dylib) ==44508==    0x374e9c: _read_images (in /usr/lib/libobjc.a.dylib) ==44508==    0x3739eb: map_images_nolock (in /usr/lib/libobjc.a.dylib) ==44508==    0x3734f3: map_images (in /usr/lib/libobjc.a.dylib) ==44508==    0x7fff5fc04936: dyld::notifybatchpartial(dyld_image_states, bool, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)) (in /usr/lib/dyld) ==44508==    0x7fff5fc0467c: dyld::registerimagestatebatchchangehandler(dyld_image_states, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)) (in /usr/lib/dyld) ==44508==    0x83ed9: dyld_register_image_state_change_handler (in /usr/lib/system/libdyld.dylib) ==44508==    0x37204c: _objc_init (in /usr/lib/libobjc.a.dylib) ==44508==  ==44508== 64 bytes in 1 blocks lost in loss record 38 of 88 ==44508==    @ 0x54d7: malloc_zone_malloc (in /usr/local/cellar/valgrind/3.8.1/lib/valgrind/vgpreload_memcheck-amd64-darwin.so) ==44508==    0x3733cf: recursive_mutex_init (in /usr/lib/libobjc.a.dylib) ==44508==    0x372025: _objc_init (in /usr/lib/libobjc.a.dylib) ==44508==    0xbb27: libsystem_initializer (in /usr/lib/libsystem.b.dylib) ==44508==    0x7fff5fc13377: imageloadermacho::domodinitfunctions(imageloader::linkcontext const&) (in /usr/lib/dyld) ==44508==    0x7fff5fc13761: imageloadermacho::doinitialization(imageloader::linkcontext const&) (in /usr/lib/dyld) ==44508==    0x7fff5fc1006d: imageloader::recursiveinitialization(imageloader::linkcontext const&, unsigned int, imageloader::initializertiminglist&) (in /usr/lib/dyld) ==44508==    0x7fff5fc0ffc3: imageloader::recursiveinitialization(imageloader::linkcontext const&, unsigned int, imageloader::initializertiminglist&) (in /usr/lib/dyld) ==44508==    0x7fff5fc0feb9: imageloader::runinitializers(imageloader::linkcontext const&, imageloader::initializertiminglist&) (in /usr/lib/dyld) ==44508==    0x7fff5fc01f9d: dyld::initializemainexecutable() (in /usr/lib/dyld) ==44508==    0x7fff5fc05b03: dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) (in /usr/lib/dyld) ==44508==    0x7fff5fc01396: dyldbootstrap::start(macho_header const*, int, char const**, long, macho_header const*, unsigned long*) (in /usr/lib/dyld) ==44508==  ==44508== 72 (24 direct, 48 indirect) bytes in 1 blocks lost in loss record 39 of 88 ==44508==    @ 0x5a95: malloc_zone_calloc (in /usr/local/cellar/valgrind/3.8.1/lib/valgrind/vgpreload_memcheck-amd64-darwin.so) ==44508==    0x3796d2: _objc_fetch_pthread_data (in /usr/lib/libobjc.a.dylib) ==44508==    0x382c4d: _fetchinitializingclasslist(signed char) (in /usr/lib/libobjc.a.dylib) ==44508==    0x379181: _class_initialize (in /usr/lib/libobjc.a.dylib) ==44508==    0x379137: _class_initialize (in /usr/lib/libobjc.a.dylib) ==44508==    0x379137: _class_initialize (in /usr/lib/libobjc.a.dylib) ==44508==    0x379137: _class_initialize (in /usr/lib/libobjc.a.dylib) ==44508==    0x3790f2: prepareformethodlookup (in /usr/lib/libobjc.a.dylib) ==44508==    0x378eee: lookupmethod (in /usr/lib/libobjc.a.dylib) ==44508==    0x3772fb: objc_msgsend (in /usr/lib/libobjc.a.dylib) ==44508==    0x2dee87: _libxpc_initializer (in /usr/lib/system/libxpc.dylib) ==44508==    0xbb2c: libsystem_initializer (in /usr/lib/libsystem.b.dylib) ==44508==  ==44508== 96 bytes in 3 blocks possibly lost in loss record 43 of 88 ==44508==    @ 0x5a95: malloc_zone_calloc (in /usr/local/cellar/valgrind/3.8.1/lib/valgrind/vgpreload_memcheck-amd64-darwin.so) ==44508==    0x3756ea: nxhashinsert (in /usr/lib/libobjc.a.dylib) ==44508==    0x38533d: realizeclass(class_t*) (in /usr/lib/libobjc.a.dylib) ==44508==    0x3845d0: realizeclass(class_t*) (in /usr/lib/libobjc.a.dylib) ==44508==    0x374e9c: _read_images (in /usr/lib/libobjc.a.dylib) ==44508==    0x3739eb: map_images_nolock (in /usr/lib/libobjc.a.dylib) ==44508==    0x3734f3: map_images (in /usr/lib/libobjc.a.dylib) ==44508==    0x7fff5fc04936: dyld::notifybatchpartial(dyld_image_states, bool, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)) (in /usr/lib/dyld) ==44508==    0x7fff5fc0467c: dyld::registerimagestatebatchchangehandler(dyld_image_states, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)) (in /usr/lib/dyld) ==44508==    0x83ed9: dyld_register_image_state_change_handler (in /usr/lib/system/libdyld.dylib) ==44508==    0x37204c: _objc_init (in /usr/lib/libobjc.a.dylib) ==44508==    0xbb27: libsystem_initializer (in /usr/lib/libsystem.b.dylib) ==44508==  ==44508== 96 bytes in 3 blocks possibly lost in loss record 44 of 88 ==44508==    @ 0x5a95: malloc_zone_calloc (in /usr/local/cellar/valgrind/3.8.1/lib/valgrind/vgpreload_memcheck-amd64-darwin.so) ==44508==    0x3756ea: nxhashinsert (in /usr/lib/libobjc.a.dylib) ==44508==    0x3757f6: _nxhashrehashtocapacity (in /usr/lib/libobjc.a.dylib) ==44508==    0x375748: nxhashinsert (in /usr/lib/libobjc.a.dylib) ==44508==    0x38533d: realizeclass(class_t*) (in /usr/lib/libobjc.a.dylib) ==44508==    0x3845d0: realizeclass(class_t*) (in /usr/lib/libobjc.a.dylib) ==44508==    0x374e9c: _read_images (in /usr/lib/libobjc.a.dylib) ==44508==    0x3739eb: map_images_nolock (in /usr/lib/libobjc.a.dylib) ==44508==    0x3734f3: map_images (in /usr/lib/libobjc.a.dylib) ==44508==    0x7fff5fc04936: dyld::notifybatchpartial(dyld_image_states, bool, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)) (in /usr/lib/dyld) ==44508==    0x7fff5fc0467c: dyld::registerimagestatebatchchangehandler(dyld_image_states, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)) (in /usr/lib/dyld) ==44508==    0x83ed9: dyld_register_image_state_change_handler (in /usr/lib/system/libdyld.dylib) ==44508==  ==44508== 120 bytes in 5 blocks possibly lost in loss record 47 of 88 ==44508==    @ 0x5a95: malloc_zone_calloc (in /usr/local/cellar/valgrind/3.8.1/lib/valgrind/vgpreload_memcheck-amd64-darwin.so) ==44508==    0x37566d: nxhashinsert (in /usr/lib/libobjc.a.dylib) ==44508==    0x3757f6: _nxhashrehashtocapacity (in /usr/lib/libobjc.a.dylib) ==44508==    0x375748: nxhashinsert (in /usr/lib/libobjc.a.dylib) ==44508==    0x38533d: realizeclass(class_t*) (in /usr/lib/libobjc.a.dylib) ==44508==    0x3845d0: realizeclass(class_t*) (in /usr/lib/libobjc.a.dylib) ==44508==    0x374e9c: _read_images (in /usr/lib/libobjc.a.dylib) ==44508==    0x3739eb: map_images_nolock (in /usr/lib/libobjc.a.dylib) ==44508==    0x3734f3: map_images (in /usr/lib/libobjc.a.dylib) ==44508==    0x7fff5fc04936: dyld::notifybatchpartial(dyld_image_states, bool, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)) (in /usr/lib/dyld) ==44508==    0x7fff5fc0467c: dyld::registerimagestatebatchchangehandler(dyld_image_states, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)) (in /usr/lib/dyld) ==44508==    0x83ed9: dyld_register_image_state_change_handler (in /usr/lib/system/libdyld.dylib) ==44508==  ... ==44508== 8,192 bytes in 8 blocks lost in loss record 86 of 88 ==44508==    @ 0x54d7: malloc_zone_malloc (in /usr/local/cellar/valgrind/3.8.1/lib/valgrind/vgpreload_memcheck-amd64-darwin.so) ==44508==    0x3745ae: objc::densemap<objc_object*, unsigned long, true, objc::densemapinfo<objc_object*>, objc::densemapinfo<unsigned long> >::init(unsigned int) (in /usr/lib/libobjc.a.dylib) ==44508==    0x37455a: arr_init (in /usr/lib/libobjc.a.dylib) ==44508==    0x3739df: map_images_nolock (in /usr/lib/libobjc.a.dylib) ==44508==    0x3734f3: map_images (in /usr/lib/libobjc.a.dylib) ==44508==    0x7fff5fc04936: dyld::notifybatchpartial(dyld_image_states, bool, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)) (in /usr/lib/dyld) ==44508==    0x7fff5fc0467c: dyld::registerimagestatebatchchangehandler(dyld_image_states, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)) (in /usr/lib/dyld) ==44508==    0x83ed9: dyld_register_image_state_change_handler (in /usr/lib/system/libdyld.dylib) ==44508==    0x37204c: _objc_init (in /usr/lib/libobjc.a.dylib) ==44508==    0xbb27: libsystem_initializer (in /usr/lib/libsystem.b.dylib) ==44508==    0x7fff5fc13377: imageloadermacho::domodinitfunctions(imageloader::linkcontext const&) (in /usr/lib/dyld) ==44508==    0x7fff5fc13761: imageloadermacho::doinitialization(imageloader::linkcontext const&) (in /usr/lib/dyld) ==44508==  ==44508== 10,808 bytes in 1 blocks possibly lost in loss record 87 of 88 ==44508==    @ 0x5237: malloc (in /usr/local/cellar/valgrind/3.8.1/lib/valgrind/vgpreload_memcheck-amd64-darwin.so) ==44508==    0x101745: tzsetwall_basic (in /usr/lib/system/libsystem_c.dylib) ==44508==    0x103043: localtime (in /usr/lib/system/libsystem_c.dylib) ==44508==    0xfb52c: gettimeofday (in /usr/lib/system/libsystem_c.dylib) ==44508==    0x1000017a0: main (in ./graph) ==44508==  ==44508== leak summary: ==44508==    lost: 9,729 bytes in 16 blocks ==44508==    indirectly lost: 1,236 bytes in 7 blocks ==44508==      possibly lost: 15,749 bytes in 68 blocks ==44508==    still reachable: 47,952 bytes in 274 blocks ==44508==         suppressed: 0 bytes in 0 blocks ==44508== reachable blocks (those pointer found) not shown. ==44508== see them, rerun with: --leak-check=full --show-reachable=yes ==44508==  ==44508== counts of detected , suppressed errors, rerun with: -v ==44508== error summary: 22 errors 22 contexts (suppressed: 0 0) 

they don't point code, still have leaks. should worried?

(also, pointers (see did there?) if i'm doing wrong or improving code style appreciated!)

you're using 3.8.1 of valgrind, latest , greatest. support osx 10.8 brought in less full version ago (3.8.0) , valgrind's news page says:

there initial support macosx 10.8, not usable serious work @ present.

the 3.8.0 version reduced noise (false positive) level on macosx 10.6/10.7 no such luck 10.8. highly recommend checking current releases on valgrind download page can subscribe there notifications of newest releases (which should bring in better support mac osx10.8)

note: valgrind 3.7.0 added support osx 10.7 have wait 3.9 come out better support.

as far "possible memory leaks" go, can suppress these warnings --show-possibly-lost=no flag, , take valgrind gives grain of salt.

that last page pointed says:

"possibly lost" means program leaking memory, unless you're doing unusual things pointers cause them point middle of allocated block; see user manual possible causes.

until new version of valgrind comes out better supports osx 10.8 highly recommend using oracle's virtualbox linux distro, can run code in there , it's free, there's a version osx 10.8. when run program on linux virtualbox see no errors reported, (keep in mind have older version) odds you're seeing false positives:

mike@mike-virtualbox:~/c$ valgrind ./a.out ==12465== memcheck, memory error detector ==12465== copyright (c) 2002-2011, , gnu gpl'd, julian seward et al. ==12465== using valgrind-3.7.0 , libvex; rerun -h copyright info ==12465== command: ./a.out ==12465==  took 43.77033 ms run ==12465==  ==12465== heap summary: ==12465==     in use @ exit: 0 bytes in 0 blocks ==12465==   total heap usage: 12,900,000 allocs, 12,900,000 frees, 284,000,000 bytes allocated ==12465==  ==12465== heap blocks freed -- no leaks possible ==12465==  ==12465== counts of detected , suppressed errors, rerun with: -v ==12465== error summary: 0 errors 0 contexts (suppressed: 2 2) mike@mike-virtualbox:~/c$  

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -