{"action":"created","issue":{"url":"https://api.github.com/repos/minetest/minetest/issues/2665","labels_url":"https://api.github.com/repos/minetest/minetest/issues/2665/labels{/name}","comments_url":"https://api.github.com/repos/minetest/minetest/issues/2665/comments","events_url":"https://api.github.com/repos/minetest/minetest/issues/2665/events","html_url":"https://github.com/minetest/minetest/issues/2665","id":72723260,"number":2665,"title":"get_perlin_map consumes all memory and brings down servers","user":{"login":"bugreport0","id":8393129,"avatar_url":"https://avatars.githubusercontent.com/u/8393129?v=3","gravatar_id":"","url":"https://api.github.com/users/bugreport0","html_url":"https://github.com/bugreport0","followers_url":"https://api.github.com/users/bugreport0/followers","following_url":"https://api.github.com/users/bugreport0/following{/other_user}","gists_url":"https://api.github.com/users/bugreport0/gists{/gist_id}","starred_url":"https://api.github.com/users/bugreport0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bugreport0/subscriptions","organizations_url":"https://api.github.com/users/bugreport0/orgs","repos_url":"https://api.github.com/users/bugreport0/repos","events_url":"https://api.github.com/users/bugreport0/events{/privacy}","received_events_url":"https://api.github.com/users/bugreport0/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/minetest/minetest/labels/@%20Mapgen","name":"@ Mapgen","color":"009800"},{"url":"https://api.github.com/repos/minetest/minetest/labels/unconfirmed%20bug","name":"unconfirmed bug","color":"dddd44"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":19,"created_at":"2015-05-03T00:30:40Z","updated_at":"2015-05-08T22:45:06Z","closed_at":null,"body":"I can't run a server properly due to this bug... the memory gets out of control and crashes minetest very often.\r\n\r\nSummary:\r\nget_perlin_map consumes insane amounts of memory more than any server can handle safely... much more than the measly 343KB that it actually contains.\r\n\r\nSteps to Reproduce:\r\nAn easy way to see this in action is with a LUA mapgen, like watershed.\r\n1. Download and install watershed:\r\nhttps://forum.minetest.net/viewtopic.php?f=9&t=8609\r\n2. Run a server\r\n3. Connect to the server on another client, use fast, fly, and noclip... and explore the map as fast as you can.\r\n4. Watch the maximum memory usage on the server process.  In testing, on my local machine I can go over 1GB.  On the server we are running the process OFTEN goes over 2GB and crashes the server.\r\n\r\nDetails of the problem:\r\nI did some testing to try and narrow down the cause.  Here's what I found out:\r\n* The problem affects various versions of minetest so appears to still be a problem.\r\n* I removed all the code in watershed except for the get_perlin_map calls.  This shows that the memory issue is in the get_perlin_map functions.\r\n\r\nFor your reference, here are the actual perlin map calls from watershed:\r\n\tlocal nvals_terrain = minetest.get_perlin_map(np_terrain, chulens):get3dMap_flat(minposxyz)\r\n\tlocal nvals_fissure = minetest.get_perlin_map(np_fissure, chulens):get3dMap_flat(minposxyz)\r\n\tlocal nvals_temp = minetest.get_perlin_map(np_temp, chulens):get3dMap_flat(minposxyz)\r\n\tlocal nvals_humid = minetest.get_perlin_map(np_humid, chulens):get3dMap_flat(minposxyz)\r\n\tlocal nvals_seam = minetest.get_perlin_map(np_seam, chulens):get3dMap_flat(minposxyz)\r\n\tlocal nvals_strata = minetest.get_perlin_map(np_strata, chulens):get3dMap_flat(minposxyz)\r\n\tlocal nvals_mid = minetest.get_perlin_map(np_mid, chulens):get2dMap_flat(minposxz)\r\n\tlocal nvals_base = minetest.get_perlin_map(np_base, chulens):get2dMap_flat(minposxz)\r\n\tlocal nvals_xlscale = minetest.get_perlin_map(np_xlscale, chulens):get2dMap_flat(minposxz)\r\n\tlocal nvals_magma = minetest.get_perlin_map(np_magma, chulens):get2dMap_flat(minposxz)\r\n\r\n\r\nNote: this is creating a big problem in running a stable server... it crashes so often."},"comment":{"url":"https://api.github.com/repos/minetest/minetest/issues/comments/100387654","html_url":"https://github.com/minetest/minetest/issues/2665#issuecomment-100387654","issue_url":"https://api.github.com/repos/minetest/minetest/issues/2665","id":100387654,"user":{"login":"paramat","id":3686677,"avatar_url":"https://avatars.githubusercontent.com/u/3686677?v=3","gravatar_id":"","url":"https://api.github.com/users/paramat","html_url":"https://github.com/paramat","followers_url":"https://api.github.com/users/paramat/followers","following_url":"https://api.github.com/users/paramat/following{/other_user}","gists_url":"https://api.github.com/users/paramat/gists{/gist_id}","starred_url":"https://api.github.com/users/paramat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paramat/subscriptions","organizations_url":"https://api.github.com/users/paramat/orgs","repos_url":"https://api.github.com/users/paramat/repos","events_url":"https://api.github.com/users/paramat/events{/privacy}","received_events_url":"https://api.github.com/users/paramat/received_events","type":"User","site_admin":false},"created_at":"2015-05-08T22:45:06Z","updated_at":"2015-05-08T22:45:06Z","body":"> Possibly related to this, when i mapgen dev and am flying at constant top speed generating terrain, my hard-drive seems to get very busy after a few minutes, constantly working instead of saving every few seconds, any idea if this is normal?\r\n\r\n> This might explain why my drive gets busy during a long session of flying and generating.\r\n\r\nOh man ignore these comments, these are for core mapgen, i confused the two =/"}}