{"action":"created","issue":{"url":"https://api.github.com/repos/CybOXProject/python-cybox/issues/290","repository_url":"https://api.github.com/repos/CybOXProject/python-cybox","labels_url":"https://api.github.com/repos/CybOXProject/python-cybox/issues/290/labels{/name}","comments_url":"https://api.github.com/repos/CybOXProject/python-cybox/issues/290/comments","events_url":"https://api.github.com/repos/CybOXProject/python-cybox/issues/290/events","html_url":"https://github.com/CybOXProject/python-cybox/issues/290","id":224221835,"number":290,"title":"Do not cache every created Object by default","user":{"login":"coolacid","id":1091410,"avatar_url":"https://avatars3.githubusercontent.com/u/1091410?v=3","gravatar_id":"","url":"https://api.github.com/users/coolacid","html_url":"https://github.com/coolacid","followers_url":"https://api.github.com/users/coolacid/followers","following_url":"https://api.github.com/users/coolacid/following{/other_user}","gists_url":"https://api.github.com/users/coolacid/gists{/gist_id}","starred_url":"https://api.github.com/users/coolacid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coolacid/subscriptions","organizations_url":"https://api.github.com/users/coolacid/orgs","repos_url":"https://api.github.com/users/coolacid/repos","events_url":"https://api.github.com/users/coolacid/events{/privacy}","received_events_url":"https://api.github.com/users/coolacid/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2017-04-25T17:56:54Z","updated_at":"2017-04-25T21:14:41Z","closed_at":null,"body":"When creating multiple Artifacts/Observables in a loop memory usage seems to jump by the object size. When using hpy from guppy to watch the python heap, it shows each iteration keeps a copy of our Observable object even though we don't do anything with it. \r\n\r\nPossible Related to #196 \r\n\r\nSimple example:\r\n`dd count=10 bs=1M if=/dev/zero of=zeros`\r\n\r\n```\r\n#!/usr/bin/env python\r\n\r\nfrom cybox.core import Observable\r\nfrom cybox.objects.artifact_object import Artifact\r\nfrom guppy import hpy\r\n\r\nwith open(\"zeros\", \"rb\") as f:\r\n    data = f.read()\r\n\r\nhp = hpy()\r\nhp.setrelheap()\r\nfor i in range (0,100):\r\n    artifact = Artifact(data, Artifact.TYPE_NETWORK)\r\n    Observable(artifact)\r\n    h = hp.heap()\r\n    print h.byrcs\r\n```\r\n\r\nRunning the above script with a zeros file created using the dd command above shows `dict of cybox.objects.artifact_object.Artifact` increasing in size each iteration. \r\n\r\nThis only happens every time you create a new Artifact and Observable. If the artifact creation line is outside of the for loop, the memory doesn't run away. \r\n\r\nWhy this is a problem:\r\n\r\nIf we're looping through a bunch of files, and creating new cybox packages and sending them out, this bug causes memory to run away until either an OOM error happens, or the script finishes. There doesn't seem to be a way to clear the heap space between creating new packages. "},"comment":{"url":"https://api.github.com/repos/CybOXProject/python-cybox/issues/comments/297167106","html_url":"https://github.com/CybOXProject/python-cybox/issues/290#issuecomment-297167106","issue_url":"https://api.github.com/repos/CybOXProject/python-cybox/issues/290","id":297167106,"user":{"login":"gtback","id":1045796,"avatar_url":"https://avatars2.githubusercontent.com/u/1045796?v=3","gravatar_id":"","url":"https://api.github.com/users/gtback","html_url":"https://github.com/gtback","followers_url":"https://api.github.com/users/gtback/followers","following_url":"https://api.github.com/users/gtback/following{/other_user}","gists_url":"https://api.github.com/users/gtback/gists{/gist_id}","starred_url":"https://api.github.com/users/gtback/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gtback/subscriptions","organizations_url":"https://api.github.com/users/gtback/orgs","repos_url":"https://api.github.com/users/gtback/repos","events_url":"https://api.github.com/users/gtback/events{/privacy}","received_events_url":"https://api.github.com/users/gtback/received_events","type":"User","site_admin":false},"created_at":"2017-04-25T21:14:41Z","updated_at":"2017-04-25T21:14:41Z","body":">Also needed to import Object from cybox.core as well.\r\n\r\nYes, sorry, I added that import to the top of my copy the script, since I was testing creating different combinations of `Observable`s, `Object`s, and `Artifact`s."}}
{"actor":{"display_login":"gtback"}}