{"id":16541567,"url":"https://github.com/codemug/marci","last_synced_at":"2025-08-08T12:08:46.654Z","repository":{"id":166429409,"uuid":"148890329","full_name":"codemug/marci","owner":"codemug","description":"Set of tools to navigate objects in a python process memory, looking into their referential relations and detecting memory leaks","archived":false,"fork":false,"pushed_at":"2018-09-15T12:52:36.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-14T08:52:22.875Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codemug.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-15T10:00:34.000Z","updated_at":"2018-09-15T12:52:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"95d3fb9a-a623-4d02-82d5-d69f80af72ba","html_url":"https://github.com/codemug/marci","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemug%2Fmarci","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemug%2Fmarci/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemug%2Fmarci/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codemug%2Fmarci/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codemug","download_url":"https://codeload.github.com/codemug/marci/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241787488,"owners_count":20020099,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T18:55:21.470Z","updated_at":"2025-03-04T04:41:59.577Z","avatar_url":"https://github.com/codemug.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n# Marci\n\n[![Build Status](https://api.travis-ci.org/codemug/marci.svg?branch=master)](https://api.travis-ci.org/codemug/marci)\n\nNavigate your python process' memory. Analyze objects and their relations to other objects.\n\n### Motivation\n\nDuring a memory leak detection spree, I came across multiple tools but I couldn't get them to analyze, navigate and traverse object graphs in memory like I wanted. My requirements forced me to use the `gc` package directly and I ended up writing snippets of memory analysis code that I needed to run again and again so I ended up packing these snippets in this package.\n\n\n### Installation\n\nTo install, simply clone the source, navigate into the cloned directory and do a:\n```\npip install .\n```\nI might be publishing a PyPi package pretty soon\n\n### Usage\n\nFire up a python interpreter in your favorite terminal and run the following code:\n\n```\nfrom marci import ObjList, Capture\nc = Capture()\nc.start()\n\n# Create some data, or do whatever needs to be observed for memory growth\nsome_data = {\n    \"string\": \"cobra\"\n}\nmore_data = [some_data]\nobj_list = c.end()\n```\nNow obj_list contains all the objects that were created between the start() and the end() method It's a list with additional methods, so you can use it as a normal list:\n```\n\u003e\u003e\u003e len(obj_list)\n7\n```\n\nAdditional methods include pretty printing\n```\n\u003e\u003e\u003e obj_list.pprint()\n(0, {})\n(1, [{'string': 'cobra'}])\n(2, ['obj_list', 'c', 'end'])\n(3, ('c', 'end', 'obj_list'))\n(4, (None,))\n(5, \u003cframe object at 0x7fdbaf32e548\u003e)\n(6, \u003cframe object at 0x7fdbaf306810\u003e)\n```\n\nType to object count summary printing\n\n```\n\u003e\u003e\u003e obj_list.psummary()\n \u003ctype 'dict'\u003e\t1\n \u003ctype 'list'\u003e\t2\n\u003ctype 'frame'\u003e\t2\n\u003ctype 'tuple'\u003e\t2\n```\n\nExtracting a specific type of objects from this list\n\n```\n\u003e\u003e\u003e l_list = obj_list.extract(list)\n\u003e\u003e\u003e l_list.pprint()\n(0, [{'string': 'cobra'}])\n(1, ['obj_list', 'c', 'end'])\n```\nOr multiple types\n\n```\n\u003e\u003e\u003e l_list = obj_list.extract([list,dict])\n\u003e\u003e\u003e l_list.pprint()\n(0, {})\n(1, [{'string': 'cobra'}])\n(2, ['obj_list', 'c', 'end'])\n```\n\nExclude specific type(s) of objects from the list\n```\n\u003e\u003e\u003e l_list = obj_list.sanitize(dict)\n\u003e\u003e\u003e l_list.pprint()\n(0, [{'string': 'cobra'}])\n(1, ['obj_list', 'c', 'end'])\n(2, ('c', 'end', 'obj_list'))\n(3, (None,))\n(4, \u003cframe object at 0x7fdbaf32e548\u003e)\n(5, \u003cframe object at 0x7fdbaf306810\u003e)\n```\nGet a list of objects that are referencing an object inside the list\n\n```\n \u003e\u003e\u003e refs = l_list.refs_to_at(0)\n \u003e\u003e\u003e refs.pprint(100)\n (0, '\u003cframe object at 0x7fdbaf2e1420\u003e')\n (1, '\u003cframe object at 0x7fdbaf2e1608\u003e')\n```\nOr a list of objects that are being referenced by an object inside the list\n```\n\u003e\u003e\u003e refs = l_list.refs_by_at(0)\n\u003e\u003e\u003e refs.pprint()\n(0, {'string': 'cobra'})\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemug%2Fmarci","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodemug%2Fmarci","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodemug%2Fmarci/lists"}