You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by srowen <gi...@git.apache.org> on 2016/03/18 11:18:40 UTC

[GitHub] spark pull request: [SPARK-13210] [SQL] catch OOM when allocate me...

Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11095#discussion_r56636220
  
    --- Diff: core/src/main/java/org/apache/spark/memory/TaskMemoryManager.java ---
    @@ -256,7 +261,20 @@ public MemoryBlock allocatePage(long size, MemoryConsumer consumer) {
           }
           allocatedPages.set(pageNumber);
         }
    -    final MemoryBlock page = memoryManager.tungstenMemoryAllocator().allocate(acquired);
    +    MemoryBlock page = null;
    +    try {
    +      page = memoryManager.tungstenMemoryAllocator().allocate(acquired);
    +    } catch (OutOfMemoryError e) {
    +      logger.warn("Failed to allocate a page ({} bytes), try again.", acquired);
    +      // there is no enough memory actually, it means the actual free memory is smaller than
    +      // MemoryManager thought, we should keep the acquired memory.
    +      acquiredButNotUsed += acquired;
    +      synchronized (this) {
    +        allocatedPages.clear(pageNumber);
    +      }
    +      // this could trigger spilling to free some pages.
    +      return allocatePage(size, consumer);
    --- End diff --
    
    I just now saw this commit but:
    Is this tail recursion a problem? if you keep running out of memory it keeps calling itself.
    `acquiredButNotUsed += acquired` needs to be synchronized too?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org