GitHub user viirya opened a pull request:

    https://github.com/apache/spark/pull/15916

    [SPARK-18487][SQL] Consume all elements for Dataset.show/take to avoid 
memory leak

    ## What changes were proposed in this pull request?
    
    The methods such as Dataset.show and take use `Limit` (i.e., 
`CollectLimitExec`) which leverages SparkPlan.executeTake to efficiently 
collect required number of elements back to the driver.
    
    However, under wholestage codege, we usually release resources after all 
elements are consumed (e.g., HashAggregate). In this case, we will not release 
the resources and cause memory leak with Dataset.show, for example.
    
    If we want to avoid the memory leak, we should consume all elements in the 
iterator.
    
    ## How was this patch tested?
    
    Added test in DatasetSuite.
    
    Please review 
https://cwiki.apache.org/confluence/display/SPARK/Contributing+to+Spark before 
opening a pull request.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/viirya/spark-1 fix-show-memory-leak

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/15916.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #15916
    
----
commit 93c93da7592327cde653815bf8a8b4c9c0193931
Author: Liang-Chi Hsieh <[email protected]>
Date:   2016-11-17T08:45:39Z

    Fix memory leak.

----


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to