{"action":"created","issue":{"url":"https://api.github.com/repos/ag-grid/ag-grid/issues/2323","repository_url":"https://api.github.com/repos/ag-grid/ag-grid","labels_url":"https://api.github.com/repos/ag-grid/ag-grid/issues/2323/labels{/name}","comments_url":"https://api.github.com/repos/ag-grid/ag-grid/issues/2323/comments","events_url":"https://api.github.com/repos/ag-grid/ag-grid/issues/2323/events","html_url":"https://github.com/ag-grid/ag-grid/issues/2323","id":315391214,"node_id":"MDU6SXNzdWUzMTUzOTEyMTQ=","number":2323,"title":"[Bug] [Memory leak] Non-deterministic memory leak when using React cell renderers","user":{"login":"hzub","id":8265332,"node_id":"MDQ6VXNlcjgyNjUzMzI=","avatar_url":"https://avatars2.githubusercontent.com/u/8265332?v=4","gravatar_id":"","url":"https://api.github.com/users/hzub","html_url":"https://github.com/hzub","followers_url":"https://api.github.com/users/hzub/followers","following_url":"https://api.github.com/users/hzub/following{/other_user}","gists_url":"https://api.github.com/users/hzub/gists{/gist_id}","starred_url":"https://api.github.com/users/hzub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hzub/subscriptions","organizations_url":"https://api.github.com/users/hzub/orgs","repos_url":"https://api.github.com/users/hzub/repos","events_url":"https://api.github.com/users/hzub/events{/privacy}","received_events_url":"https://api.github.com/users/hzub/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-04-18T09:01:48Z","updated_at":"2018-10-01T22:12:43Z","closed_at":null,"author_association":"NONE","body":"**I'm submitting a ...**  (check one with \"x\")\r\n```\r\n[x] bug report\r\n[ ] feature request\r\n[ ] support request\r\n```\r\n\r\n**Current behavior**\r\nWhen using `cellRendererFramework` in column definition and putting React components there, I've encountered a following scenario: React components get mounted **twice** upon grid initialization, but demounted only **once** when grid is destroyed - which causes half of them to remain in memory and take up the space.\r\nThis behavior, however, is caused **only** when we're trying to render React components in one of leftmost columns of the grid. The bug **does not** occur when we're choosing last columns of the grid as the container for our React component cells. This is super weird, but it indicates that bug might be related to some race condition.\r\nExact configuration, scenario and even a short movies are in \"reproduction\" section below.\r\n\r\n**Expected behavior**\r\nReact components serving as cell renderers are mounted properly upon initialization and unmounted completely upon grid destruction.\r\n\r\n**Minimal reproduction of the problem with instructions**\r\n\r\nThe dataset:\r\n```\r\n[\r\n  {\r\n    \"Id\": \"0\",\r\n    \"testField\": \"quis aliqua do\",\r\n    \"testField2\": \"dummy1\"\r\n  },\r\n  {\r\n    \"Id\": \"1\",\r\n    \"testField\": \"commodo proident ut\",\r\n    \"testField2\": \"dummy2\"\r\n  },\r\n  {\r\n    \"Id\": \"2\",\r\n    \"testField\": \"nisi dolor ut\",\r\n    \"testField2\": \"dummy3\"\r\n  }\r\n]\r\n```\r\n\r\nThe column definition **which cause** the memory leak (scenario 1):\r\n```\r\nconst columns = [\r\n  {\r\n    field: 'testField',\r\n    headerName: 'Lorem ipsum',\r\n  },\r\n  {\r\n    field: 'testField2',\r\n    headerName: 'Test field',\r\n    cellRendererFramework: () => <div>Example</div>,\r\n  },\r\n];\r\n```\r\n\r\nThe column definition **which doesn't cause** the memory leak (scenario 2):\r\n```\r\nconst columns = [\r\n  {\r\n    field: 'testField',\r\n    headerName: 'Lorem ipsum',\r\n  },\r\n  {\r\n    field: 'someDummyField',\r\n    field: 'Foo bar',\r\n  },\r\n  {\r\n    field: 'anotherDummyField',\r\n    field: 'Foo baz',\r\n  },\r\n  {\r\n    field: 'testField2',\r\n    headerName: 'Test field',\r\n    cellRendererFramework: () => <div>Example</div>,\r\n  },\r\n];\r\n```\r\n\r\nField and headers names, labels etc. doesn't matter here. What does matter (and is weird) is the column order.\r\n\r\nMemory leak visible in scenario 1 (movie, .mov in ZIP):\r\n[aggridscenario1.mov.zip](https://github.com/ag-grid/ag-grid/files/1923159/aggridscenario1.mov.zip)\r\n\r\nMemory leak not occuring in scenario 2 (movie, .mov in ZIP):\r\n[aggridscenario2.mov.zip](https://github.com/ag-grid/ag-grid/files/1923163/aggridscenario2.mov.zip)\r\n\r\n*Info that might be relevant:* \r\n- ag-grid is placed with help of `<AgGridReact />` component.\r\n- data is set by props.\r\n- columns are set by props, but until they appear there - first they're initialized in `gridReady()` event.\r\n- i'm using `columnApi.setColumnState()` to set proper columns widths/visibility, which is called just after setting the columns\r\n\r\n**Please tell us about your environment:**\r\n\r\nmacOS High Sierra 10.13.3, Chrome 65.0.3325.181\r\n\r\n* **ag-Grid version:** 17.1.1\r\n\r\n* **Browser:** Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36\r\n\r\n* **Language:** ES6/7\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ag-grid/ag-grid/issues/comments/426081691","html_url":"https://github.com/ag-grid/ag-grid/issues/2323#issuecomment-426081691","issue_url":"https://api.github.com/repos/ag-grid/ag-grid/issues/2323","id":426081691,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNjA4MTY5MQ==","user":{"login":"biels","id":5158960,"node_id":"MDQ6VXNlcjUxNTg5NjA=","avatar_url":"https://avatars3.githubusercontent.com/u/5158960?v=4","gravatar_id":"","url":"https://api.github.com/users/biels","html_url":"https://github.com/biels","followers_url":"https://api.github.com/users/biels/followers","following_url":"https://api.github.com/users/biels/following{/other_user}","gists_url":"https://api.github.com/users/biels/gists{/gist_id}","starred_url":"https://api.github.com/users/biels/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/biels/subscriptions","organizations_url":"https://api.github.com/users/biels/orgs","repos_url":"https://api.github.com/users/biels/repos","events_url":"https://api.github.com/users/biels/events{/privacy}","received_events_url":"https://api.github.com/users/biels/received_events","type":"User","site_admin":false},"created_at":"2018-10-01T22:12:43Z","updated_at":"2018-10-01T22:12:43Z","author_association":"NONE","body":"Same thing here"}}
{"actor":{"display_login":"biels"}}