Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-15919

MemoryManager shouldn't allow releasing more memory than reserved

    XMLWordPrintableJSON

Details

    Description

      Currently MemoryManager allows releasing more memory than reserved for the same owner object, which could be reproduced by adding below test case into MemoryManagerTest:

      	@Test
      	public void testMemoryReleaseGuard() throws MemoryReservationException {
      		Object owner = new Object();
      		Object owner2 = new Object();
      
      		long totalHeapMemorySize = memoryManager.availableMemory(MemoryType.HEAP);
      		memoryManager.reserveMemory(owner, MemoryType.HEAP, PAGE_SIZE);
      		memoryManager.reserveMemory(owner2, MemoryType.HEAP, PAGE_SIZE);
      		memoryManager.releaseMemory(owner, MemoryType.HEAP, PAGE_SIZE);
      		memoryManager.releaseMemory(owner, MemoryType.HEAP, PAGE_SIZE);
      		long heapMemoryLeft = memoryManager.availableMemory(MemoryType.HEAP);
      		assertEquals("Memory leak happens", totalHeapMemorySize - PAGE_SIZE, heapMemoryLeft);
      		memoryManager.releaseAllMemory(owner2, MemoryType.HEAP);
      	}
      

      Attachments

        Issue Links

          Activity

            People

              liyu Yu Li
              liyu Yu Li
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m