public long cleanUpAllAllocatedMemory ( ) { synchronized ( this ) { for ( MemoryConsumer c : consumers ) { if ( c != null && c . getUsed ( ) > 0 ) { // In case of failed task, it's normal to see leaked memory logger . debug ( "unreleased " + Utils . bytesToString ( c . getUsed ( ) ) + " memory from " + c ) ; } } consumers . clear ( ) ; for ( MemoryBlock page : pageTable ) { if ( page != null ) { logger . debug ( "unreleased page: " + page + " in task " + taskAttemptId ) ; page . pageNumber = MemoryBlock . FREED_IN_TMM_PAGE_NUMBER ; memoryManager . tungstenMemoryAllocator ( ) . free ( page ) ; } } Arrays . fill ( pageTable , null ) ; } // release the memory that is not used by any consumer (acquired for pages in tungsten mode). memoryManager . releaseExecutionMemory ( acquiredButNotUsed , taskAttemptId , tungstenMemoryMode ) ; return memoryManager . releaseAllExecutionMemoryForTask ( taskAttemptId ) ; }
Clean up all allocated memory and pages . Returns the number of bytes freed . A non - zero return value can be used to detect memory leaks .