{"action":"closed","issue":{"url":"https://api.github.com/repos/ellson/graphviz/issues/911","repository_url":"https://api.github.com/repos/ellson/graphviz","labels_url":"https://api.github.com/repos/ellson/graphviz/issues/911/labels{/name}","comments_url":"https://api.github.com/repos/ellson/graphviz/issues/911/comments","events_url":"https://api.github.com/repos/ellson/graphviz/issues/911/events","html_url":"https://github.com/ellson/graphviz/issues/911","id":163747664,"number":911,"title":"[Dot] memory leak if directional graph contains cycles","user":{"login":"GadgetSteve","id":5593690,"avatar_url":"https://avatars.githubusercontent.com/u/5593690?v=3","gravatar_id":"","url":"https://api.github.com/users/GadgetSteve","html_url":"https://github.com/GadgetSteve","followers_url":"https://api.github.com/users/GadgetSteve/followers","following_url":"https://api.github.com/users/GadgetSteve/following{/other_user}","gists_url":"https://api.github.com/users/GadgetSteve/gists{/gist_id}","starred_url":"https://api.github.com/users/GadgetSteve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GadgetSteve/subscriptions","organizations_url":"https://api.github.com/users/GadgetSteve/orgs","repos_url":"https://api.github.com/users/GadgetSteve/repos","events_url":"https://api.github.com/users/GadgetSteve/events{/privacy}","received_events_url":"https://api.github.com/users/GadgetSteve/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-04T22:20:14Z","updated_at":"2016-07-09T10:06:43Z","closed_at":"2016-07-09T10:06:43Z","body":"Ported Issue from Mantis\r\nOriginal ID: 1168\r\nReported By: Willem Kokke\r\n\r\nSEVERITY: MINOR\r\nSubmitted: 2006-08-16 16:13:16\r\n\r\nOS: *-*-*\r\n\r\nVERSION: 2.9\r\n\r\n\r\nDESCRIPTION\r\n-----------\r\n\r\n<br>\r\n\r\nIf a graph has cycles, graphviz tries to break the cycles by reversing the edge. The code to do this seems to cause a memory leak.\r\n<br>\r\n\r\nThis can be easily demostrated by replacing the create_test_graph function in dot.c with\r\n<CD>\r\n```\r\nstatic graph_t *create_test_graph(void)\r\n{\r\n    Agnode_t *node[3];\r\n    Agraph_t *g;\r\n<br>\r\n\r\n    g = agopen(\"new_graph\", AGDIGRAPH);\r\n<br>\r\n\r\n    node[0] = agnode(g, \"0\");\r\n    node[1] = agnode(g, \"1\");\r\n    node[2] = agnode(g, \"2\");\r\n<br>\r\n\r\n    agedge(g, node[0], node[1]);\r\n    agedge(g, node[1], node[2]);\r\n    agedge(g, node[2], node[0]);\r\n<br>\r\n\r\n    return g;\r\n}\r\n```\r\n</CD>\r\n<br>\r\n\r\nand then running it with the -m flag to observe the memory increase.\r\nWith the original create_test_graph, the memory foot print did not increase\r\n<br>\r\n\r\nI've compiled graphviz and dot with visual studio 2003 and 2005, both exhibit the same behaviour.\r\nI've first detected it with my own modified version of graphviz, but later verified it with the stock development snapshot\r\n\r\n\r\nSTEPS TO REPRODUCE\r\n------------------\r\n\r\n```\r\n\r\ndigraph example{\r\n    a -> b -> c -> a\r\n}\r\n\r\n```\r\n\r\nADDITIONAL INFORMATION\r\n----------------------\r\n\r\n\r\nWith the help of various tools, I've found out where this leak occurs exactly\r\n\r\nit seems for each cycle in the graph it leaks 168 bytes per layout step\r\nThe exact location of the memory leak and call stack at that time is as follows:\r\n\r\n<CD>\r\n```\r\n---------- Block 336 at 0x007DAFA0: 168 bytes ----------\r\n  Call Stack:\r\n    d:\\work\\graphviz-bug\\graphviz-win-devel\\lib\\common\\memory.c (52): gmalloc\r\n    d:\\work\\graphviz-bug\\graphviz-win-devel\\lib\\common\\memory.c (30): zmalloc\r\n    d:\\work\\graphviz-bug\\graphviz-win-devel\\lib\\dotgen\\fastgr.c (169): new_virtual_edge\r\n    d:\\work\\graphviz-bug\\graphviz-win-devel\\lib\\dotgen\\fastgr.c (199): virtual_edge\r\n    d:\\work\\graphviz-bug\\graphviz-win-devel\\lib\\dotgen\\acyclic.c (32): reverse_edge\r\n    d:\\work\\graphviz-bug\\graphviz-win-devel\\lib\\dotgen\\acyclic.c (49): dfs\r\n    d:\\work\\graphviz-bug\\graphviz-win-devel\\lib\\dotgen\\acyclic.c (53): dfs\r\n    d:\\work\\graphviz-bug\\graphviz-win-devel\\lib\\dotgen\\acyclic.c (53): dfs\r\n    d:\\work\\graphviz-bug\\graphviz-win-devel\\lib\\dotgen\\acyclic.c (70): acyclic\r\n    d:\\work\\graphviz-bug\\graphviz-win-devel\\lib\\dotgen\\rank.c (473): dot_rank\r\n    d:\\work\\graphviz-bug\\graphviz-win-devel\\lib\\dotgen\\dotinit.c (226): dot_layout\r\n    d:\\work\\graphviz-bug\\graphviz-win-devel\\lib\\gvc\\gvlayout.c (68): gvLayoutJobs\r\n    d:\\work\\graphviz-bug\\graphviz-win-devel\\cmd\\dot\\dot.c (155): main\r\n    f:\\vs70builds\\3077\\vc\\crtbld\\crt\\src\\c]\r\n```\r\n</CD>\r\n"}}
{"actor":{"display_login":"GadgetSteve"}}