{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/27083960","id":27083960,"diff_hunk":"@@ -97,11 +117,11 @@ private[spark] class MemoryStore(blockManager: BlockManager, maxMemory: Long)\n       returnValues: Boolean): PutResult = {\n     if (level.deserialized) {\n       val sizeEstimate = SizeEstimator.estimate(values.asInstanceOf[AnyRef])\n-      val putAttempt = tryToPut(blockId, values, sizeEstimate, deserialized = true)\n+      val putAttempt = tryToPut(blockId, () => values, sizeEstimate, deserialized = true)\n       PutResult(sizeEstimate, Left(values.iterator), putAttempt.droppedBlocks)\n     } else {\n       val bytes = blockManager.dataSerialize(blockId, values.iterator)\n-      val putAttempt = tryToPut(blockId, bytes, bytes.limit, deserialized = false)\n+      val putAttempt = tryToPut(blockId, () => bytes, bytes.limit, deserialized = false)","path":"core/src/main/scala/org/apache/spark/storage/MemoryStore.scala","position":43,"original_position":43,"commit_id":"1100a5469e6ac16e3246748912b61e864c0dbe4a","original_commit_id":"1100a5469e6ac16e3246748912b61e864c0dbe4a","user":{"login":"andrewor14","id":2133137,"avatar_url":"https://avatars.githubusercontent.com/u/2133137?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewor14","html_url":"https://github.com/andrewor14","followers_url":"https://api.github.com/users/andrewor14/followers","following_url":"https://api.github.com/users/andrewor14/following{/other_user}","gists_url":"https://api.github.com/users/andrewor14/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewor14/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewor14/subscriptions","organizations_url":"https://api.github.com/users/andrewor14/orgs","repos_url":"https://api.github.com/users/andrewor14/repos","events_url":"https://api.github.com/users/andrewor14/events{/privacy}","received_events_url":"https://api.github.com/users/andrewor14/received_events","type":"User","site_admin":false},"body":"it's a little odd for this to be `() => bytes` everywhere. Can you create an alias that looks something like:\r\n```\r\nprivate def tryToPut(blockId: BlockId, value: Any, ...): ResultWithDroppedBlocks = {\r\n  tryToPut(blockId, () => value(), ...)\r\n}\r\n```\r\nsame with dropFromMemory","created_at":"2015-03-24T23:33:51Z","updated_at":"2015-03-24T23:33:51Z","html_url":"https://github.com/apache/spark/pull/4827#discussion_r27083960","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/4827","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/27083960"},"html":{"href":"https://github.com/apache/spark/pull/4827#discussion_r27083960"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/4827"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/4827","id":30220010,"html_url":"https://github.com/apache/spark/pull/4827","diff_url":"https://github.com/apache/spark/pull/4827.diff","patch_url":"https://github.com/apache/spark/pull/4827.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/4827","number":4827,"state":"open","locked":false,"title":"[SPARK-6076][Block Manager] Fix a potential OOM issue when StorageLevel is MEMORY_AND_DISK_SER","user":{"login":"zsxwing","id":1000778,"avatar_url":"https://avatars.githubusercontent.com/u/1000778?v=3","gravatar_id":"","url":"https://api.github.com/users/zsxwing","html_url":"https://github.com/zsxwing","followers_url":"https://api.github.com/users/zsxwing/followers","following_url":"https://api.github.com/users/zsxwing/following{/other_user}","gists_url":"https://api.github.com/users/zsxwing/gists{/gist_id}","starred_url":"https://api.github.com/users/zsxwing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zsxwing/subscriptions","organizations_url":"https://api.github.com/users/zsxwing/orgs","repos_url":"https://api.github.com/users/zsxwing/repos","events_url":"https://api.github.com/users/zsxwing/events{/privacy}","received_events_url":"https://api.github.com/users/zsxwing/received_events","type":"User","site_admin":false},"body":"In https://github.com/apache/spark/blob/dcd1e42d6b6ac08d2c0736bf61a15f515a1f222b/core/src/main/scala/org/apache/spark/storage/BlockManager.scala#L538 , when StorageLevel is `MEMORY_AND_DISK_SER`, it will copy the content from file into memory, then put it into MemoryStore.\r\n```scala\r\n              val copyForMemory = ByteBuffer.allocate(bytes.limit)\r\n              copyForMemory.put(bytes)\r\n              memoryStore.putBytes(blockId, copyForMemory, level)\r\n              bytes.rewind()\r\n```\r\nHowever, if the file is bigger than the free memory, OOM will happen. A better approach is testing if there is enough memory. If not, copyForMemory should not be created, since this is an optional operation.","created_at":"2015-02-28T06:51:20Z","updated_at":"2015-03-24T23:33:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"80e7cb31aa995d35b5c5c7da88cfb996fe149f56","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/4827/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/4827/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/4827/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/1100a5469e6ac16e3246748912b61e864c0dbe4a","head":{"label":"zsxwing:SPARK-6076","ref":"SPARK-6076","sha":"1100a5469e6ac16e3246748912b61e864c0dbe4a","user":{"login":"zsxwing","id":1000778,"avatar_url":"https://avatars.githubusercontent.com/u/1000778?v=3","gravatar_id":"","url":"https://api.github.com/users/zsxwing","html_url":"https://github.com/zsxwing","followers_url":"https://api.github.com/users/zsxwing/followers","following_url":"https://api.github.com/users/zsxwing/following{/other_user}","gists_url":"https://api.github.com/users/zsxwing/gists{/gist_id}","starred_url":"https://api.github.com/users/zsxwing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zsxwing/subscriptions","organizations_url":"https://api.github.com/users/zsxwing/orgs","repos_url":"https://api.github.com/users/zsxwing/repos","events_url":"https://api.github.com/users/zsxwing/events{/privacy}","received_events_url":"https://api.github.com/users/zsxwing/received_events","type":"User","site_admin":false},"repo":{"id":17894272,"name":"spark","full_name":"zsxwing/spark","owner":{"login":"zsxwing","id":1000778,"avatar_url":"https://avatars.githubusercontent.com/u/1000778?v=3","gravatar_id":"","url":"https://api.github.com/users/zsxwing","html_url":"https://github.com/zsxwing","followers_url":"https://api.github.com/users/zsxwing/followers","following_url":"https://api.github.com/users/zsxwing/following{/other_user}","gists_url":"https://api.github.com/users/zsxwing/gists{/gist_id}","starred_url":"https://api.github.com/users/zsxwing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zsxwing/subscriptions","organizations_url":"https://api.github.com/users/zsxwing/orgs","repos_url":"https://api.github.com/users/zsxwing/repos","events_url":"https://api.github.com/users/zsxwing/events{/privacy}","received_events_url":"https://api.github.com/users/zsxwing/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zsxwing/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/zsxwing/spark","forks_url":"https://api.github.com/repos/zsxwing/spark/forks","keys_url":"https://api.github.com/repos/zsxwing/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zsxwing/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zsxwing/spark/teams","hooks_url":"https://api.github.com/repos/zsxwing/spark/hooks","issue_events_url":"https://api.github.com/repos/zsxwing/spark/issues/events{/number}","events_url":"https://api.github.com/repos/zsxwing/spark/events","assignees_url":"https://api.github.com/repos/zsxwing/spark/assignees{/user}","branches_url":"https://api.github.com/repos/zsxwing/spark/branches{/branch}","tags_url":"https://api.github.com/repos/zsxwing/spark/tags","blobs_url":"https://api.github.com/repos/zsxwing/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zsxwing/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zsxwing/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/zsxwing/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zsxwing/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/zsxwing/spark/languages","stargazers_url":"https://api.github.com/repos/zsxwing/spark/stargazers","contributors_url":"https://api.github.com/repos/zsxwing/spark/contributors","subscribers_url":"https://api.github.com/repos/zsxwing/spark/subscribers","subscription_url":"https://api.github.com/repos/zsxwing/spark/subscription","commits_url":"https://api.github.com/repos/zsxwing/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/zsxwing/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/zsxwing/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/zsxwing/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/zsxwing/spark/contents/{+path}","compare_url":"https://api.github.com/repos/zsxwing/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zsxwing/spark/merges","archive_url":"https://api.github.com/repos/zsxwing/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zsxwing/spark/downloads","issues_url":"https://api.github.com/repos/zsxwing/spark/issues{/number}","pulls_url":"https://api.github.com/repos/zsxwing/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/zsxwing/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/zsxwing/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zsxwing/spark/labels{/name}","releases_url":"https://api.github.com/repos/zsxwing/spark/releases{/id}","created_at":"2014-03-19T06:21:04Z","updated_at":"2015-03-09T07:52:42Z","pushed_at":"2015-03-24T12:51:35Z","git_url":"git://github.com/zsxwing/spark.git","ssh_url":"git@github.com:zsxwing/spark.git","clone_url":"https://github.com/zsxwing/spark.git","svn_url":"https://github.com/zsxwing/spark","homepage":null,"size":92693,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"dba08d1fc3bdb9245aefe695970354df088a93b6","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":17165658,"name":"spark","full_name":"apache/spark","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/spark","description":"Mirror of Apache Spark","fork":false,"url":"https://api.github.com/repos/apache/spark","forks_url":"https://api.github.com/repos/apache/spark/forks","keys_url":"https://api.github.com/repos/apache/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/spark/teams","hooks_url":"https://api.github.com/repos/apache/spark/hooks","issue_events_url":"https://api.github.com/repos/apache/spark/issues/events{/number}","events_url":"https://api.github.com/repos/apache/spark/events","assignees_url":"https://api.github.com/repos/apache/spark/assignees{/user}","branches_url":"https://api.github.com/repos/apache/spark/branches{/branch}","tags_url":"https://api.github.com/repos/apache/spark/tags","blobs_url":"https://api.github.com/repos/apache/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/spark/languages","stargazers_url":"https://api.github.com/repos/apache/spark/stargazers","contributors_url":"https://api.github.com/repos/apache/spark/contributors","subscribers_url":"https://api.github.com/repos/apache/spark/subscribers","subscription_url":"https://api.github.com/repos/apache/spark/subscription","commits_url":"https://api.github.com/repos/apache/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/spark/contents/{+path}","compare_url":"https://api.github.com/repos/apache/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/spark/merges","archive_url":"https://api.github.com/repos/apache/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/spark/downloads","issues_url":"https://api.github.com/repos/apache/spark/issues{/number}","pulls_url":"https://api.github.com/repos/apache/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/spark/labels{/name}","releases_url":"https://api.github.com/repos/apache/spark/releases{/id}","created_at":"2014-02-25T08:00:08Z","updated_at":"2015-03-24T23:30:03Z","pushed_at":"2015-03-24T23:33:07Z","git_url":"git://github.com/apache/spark.git","ssh_url":"git@github.com:apache/spark.git","clone_url":"https://github.com/apache/spark.git","svn_url":"https://github.com/apache/spark","homepage":null,"size":1432017,"stargazers_count":3352,"watchers_count":3352,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2888,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":296,"forks":2888,"open_issues":296,"watchers":3352,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/4827"},"html":{"href":"https://github.com/apache/spark/pull/4827"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/4827"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/4827/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/4827/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/4827/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/1100a5469e6ac16e3246748912b61e864c0dbe4a"}}}}