{"action":"created","issue":{"url":"https://api.github.com/repos/tgriesser/knex/issues/1457","repository_url":"https://api.github.com/repos/tgriesser/knex","labels_url":"https://api.github.com/repos/tgriesser/knex/issues/1457/labels{/name}","comments_url":"https://api.github.com/repos/tgriesser/knex/issues/1457/comments","events_url":"https://api.github.com/repos/tgriesser/knex/issues/1457/events","html_url":"https://github.com/tgriesser/knex/issues/1457","id":157337242,"number":1457,"title":"knex memory leak from 0.11.2","user":{"login":"Chyzwar","id":5990767,"avatar_url":"https://avatars.githubusercontent.com/u/5990767?v=3","gravatar_id":"","url":"https://api.github.com/users/Chyzwar","html_url":"https://github.com/Chyzwar","followers_url":"https://api.github.com/users/Chyzwar/followers","following_url":"https://api.github.com/users/Chyzwar/following{/other_user}","gists_url":"https://api.github.com/users/Chyzwar/gists{/gist_id}","starred_url":"https://api.github.com/users/Chyzwar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Chyzwar/subscriptions","organizations_url":"https://api.github.com/users/Chyzwar/orgs","repos_url":"https://api.github.com/users/Chyzwar/repos","events_url":"https://api.github.com/users/Chyzwar/events{/privacy}","received_events_url":"https://api.github.com/users/Chyzwar/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/tgriesser/knex/labels/More%20information%20requested","name":"More information requested","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-05-28T12:48:48Z","updated_at":"2016-06-01T07:31:29Z","closed_at":null,"body":"Hi, \r\n\r\nWhen using seed API I have memory leak for knex 0.11.2 and above.\r\n\r\n30 sec after starting seed:\r\n![knex-1](https://cloud.githubusercontent.com/assets/5990767/15627352/47f00d7a-24d9-11e6-8f6b-8d94ad46251e.png)\r\n\r\naround 10 min later:\r\n![knex-2](https://cloud.githubusercontent.com/assets/5990767/15627382/e62e78a0-24d9-11e6-9f96-c2e674a33b52.png)\r\n\r\n\r\nand its crash in around 30 min (gradually slow down as well):\r\n![knex-3](https://cloud.githubusercontent.com/assets/5990767/15627488/a8e05046-24dd-11e6-839b-96deb1c07ece.png)\r\n\r\nCode to reproduce:\r\n\r\n```js\r\nimport faker from 'faker';\r\n\r\n/* eslint no-console: \"allow\" */\r\nfunction generate(iterations, perIteration, knex, tableName, generator) {\r\n  console.log(tableName, iterations * perIteration);\r\n\r\n  return knex\r\n    .batchInsert(tableName, generator(perIteration))\r\n    .then(() => {\r\n\r\n      if (iterations) {\r\n        return generate(iterations - 1, perIteration, knex, tableName, generator);\r\n      }\r\n    });\r\n}\r\n\r\nfunction usersGen(number) {\r\n  const newUsers = [];\r\n\r\n  for (let i = 0; i <= number; i++) {\r\n    newUsers.push({\r\n      firstName: faker.name.lastName(),\r\n      lastName: faker.name.firstName(),\r\n      userName: faker.internet.userName(),\r\n      password: faker.internet.password(),\r\n      avatar: faker.image.avatar(),\r\n      email: faker.internet.email(),\r\n      createdAt: faker.date.past(),\r\n      groupId: 3,\r\n    });\r\n  }\r\n  return newUsers;\r\n}\r\n\r\nexports.seed = (knex, Promise) => {\r\n  console.log('User seeder, starting');\r\n\r\n  return Promise.join(\r\n    knex('users').truncate(),\r\n\r\n    /**\r\n     * Generate 10 milions of users,\r\n     * 10000 iterations and 1000 each\r\n     */\r\n    generate(10000, 1000, knex, 'users', usersGen)\r\n  );\r\n};\r\n\r\n```\r\n\r\nI was reading knex code but there was huge refactoring when moving to es6. For version 0.11.1 memory usage is stable around 100mb."},"comment":{"url":"https://api.github.com/repos/tgriesser/knex/issues/comments/222915068","html_url":"https://github.com/tgriesser/knex/issues/1457#issuecomment-222915068","issue_url":"https://api.github.com/repos/tgriesser/knex/issues/1457","id":222915068,"user":{"login":"Chyzwar","id":5990767,"avatar_url":"https://avatars.githubusercontent.com/u/5990767?v=3","gravatar_id":"","url":"https://api.github.com/users/Chyzwar","html_url":"https://github.com/Chyzwar","followers_url":"https://api.github.com/users/Chyzwar/followers","following_url":"https://api.github.com/users/Chyzwar/following{/other_user}","gists_url":"https://api.github.com/users/Chyzwar/gists{/gist_id}","starred_url":"https://api.github.com/users/Chyzwar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Chyzwar/subscriptions","organizations_url":"https://api.github.com/users/Chyzwar/orgs","repos_url":"https://api.github.com/users/Chyzwar/repos","events_url":"https://api.github.com/users/Chyzwar/events{/privacy}","received_events_url":"https://api.github.com/users/Chyzwar/received_events","type":"User","site_admin":false},"created_at":"2016-06-01T07:31:29Z","updated_at":"2016-06-01T07:31:29Z","body":"Leak happen 0.11.2 and above. 0.11.1 is safe. When I was was looking into source in version 0.11.2 there was a lot commits related to es6. \r\n\r\nI am using MariaDB, maybe below is related, \r\nhttps://github.com/mscdex/node-mariasql/issues/144"}}
{"actor":{"display_login":"Chyzwar"}}