{"action":"opened","issue":{"url":"https://api.github.com/repos/kivy/pyjnius/issues/155","labels_url":"https://api.github.com/repos/kivy/pyjnius/issues/155/labels{/name}","comments_url":"https://api.github.com/repos/kivy/pyjnius/issues/155/comments","events_url":"https://api.github.com/repos/kivy/pyjnius/issues/155/events","html_url":"https://github.com/kivy/pyjnius/issues/155","id":68704133,"number":155,"title":"Memory leak when passing arrays of strings as methods' arguments","user":{"login":"fabiofabris","id":5780420,"avatar_url":"https://avatars.githubusercontent.com/u/5780420?v=3","gravatar_id":"","url":"https://api.github.com/users/fabiofabris","html_url":"https://github.com/fabiofabris","followers_url":"https://api.github.com/users/fabiofabris/followers","following_url":"https://api.github.com/users/fabiofabris/following{/other_user}","gists_url":"https://api.github.com/users/fabiofabris/gists{/gist_id}","starred_url":"https://api.github.com/users/fabiofabris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabiofabris/subscriptions","organizations_url":"https://api.github.com/users/fabiofabris/orgs","repos_url":"https://api.github.com/users/fabiofabris/repos","events_url":"https://api.github.com/users/fabiofabris/events{/privacy}","received_events_url":"https://api.github.com/users/fabiofabris/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-15T14:56:25Z","updated_at":"2015-04-15T14:56:25Z","closed_at":null,"body":"Hello all.\r\n\r\nI've been experience some \"out of memory\" errors when using pyjnius, specially when passing arrays of strings to methods. Here is an example:\r\n\r\nConsider this sample python file:\r\n\r\n```python\r\nimport sys\r\nimport jnius_config\r\njnius_config.add_options('-Xms100M', '-Xmx100M')\r\n\r\nfrom jnius import autoclass\r\n\r\nTestFactory = autoclass('test.Test')\r\ntest = TestFactory()\r\n\r\nfor c in xrange(int(sys.argv[1])):\r\n    arg = [\"some string\" for _ in xrange(1000)]\r\n    test.test(arg)\r\n    print \"counter:\", c\r\n```\r\n\r\nAnd the corresponding java implementation:\r\n\r\n```java\r\npackage test;\r\n\r\npublic class Test{\r\n    public void test(String[] arg){}\r\n    public void test_noarg(){}\r\n}\r\n```\r\n\r\nWhat I've been experiencing is that after around 1600 test.test(arg) calls, the process struggles with memory, eventually crashing. This does not happen if one substitutes test.test(arg) for test.test_noarg(), what points to a problem in the handling of String arrays arguments. In fact, valgrind --leak-check=full reports that several bytes are lost at line 538 of jnius_conversion.pxi ( j_string = j_env[0].NewStringUTF(j_env, <bytes>arg)).\r\n\r\nAnd if I comment-out lines 538 to 542, the problem disappears. \r\n```python\r\n                # j_string = j_env[0].NewStringUTF(\r\n                #         j_env, arg)\r\n                #\r\n                # j_env[0].SetObjectArrayElement(\r\n                #         j_env, <jobjectArray>ret, i, j_string)\r\n```\r\n\r\nI'm using pyjnius version 1.1-dev, Cython-0.22, java version \"1.7.0_25\", python version 2.7.4 under Linux Mint 15.\r\n\r\n\r\n\r\n\r\n"}}