{"action":"created","issue":{"url":"https://api.github.com/repos/ehcache/ehcache3/issues/1477","repository_url":"https://api.github.com/repos/ehcache/ehcache3","labels_url":"https://api.github.com/repos/ehcache/ehcache3/issues/1477/labels{/name}","comments_url":"https://api.github.com/repos/ehcache/ehcache3/issues/1477/comments","events_url":"https://api.github.com/repos/ehcache/ehcache3/issues/1477/events","html_url":"https://github.com/ehcache/ehcache3/issues/1477","id":180646056,"number":1477,"title":"Memory from Offheap tier is not reclaimed after a cachemanager.close()","user":{"login":"aurbroszniowski","id":1264251,"avatar_url":"https://avatars.githubusercontent.com/u/1264251?v=3","gravatar_id":"","url":"https://api.github.com/users/aurbroszniowski","html_url":"https://github.com/aurbroszniowski","followers_url":"https://api.github.com/users/aurbroszniowski/followers","following_url":"https://api.github.com/users/aurbroszniowski/following{/other_user}","gists_url":"https://api.github.com/users/aurbroszniowski/gists{/gist_id}","starred_url":"https://api.github.com/users/aurbroszniowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aurbroszniowski/subscriptions","organizations_url":"https://api.github.com/users/aurbroszniowski/orgs","repos_url":"https://api.github.com/users/aurbroszniowski/repos","events_url":"https://api.github.com/users/aurbroszniowski/events{/privacy}","received_events_url":"https://api.github.com/users/aurbroszniowski/received_events","type":"User","site_admin":false},"labels":[{"id":82913211,"url":"https://api.github.com/repos/ehcache/ehcache3/labels/bug","name":"bug","color":"fc2929","default":true},{"id":119748874,"url":"https://api.github.com/repos/ehcache/ehcache3/labels/in%20progress","name":"in progress","color":"5319e7","default":false}],"state":"open","locked":false,"assignee":{"login":"henri-tremblay","id":1216819,"avatar_url":"https://avatars.githubusercontent.com/u/1216819?v=3","gravatar_id":"","url":"https://api.github.com/users/henri-tremblay","html_url":"https://github.com/henri-tremblay","followers_url":"https://api.github.com/users/henri-tremblay/followers","following_url":"https://api.github.com/users/henri-tremblay/following{/other_user}","gists_url":"https://api.github.com/users/henri-tremblay/gists{/gist_id}","starred_url":"https://api.github.com/users/henri-tremblay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henri-tremblay/subscriptions","organizations_url":"https://api.github.com/users/henri-tremblay/orgs","repos_url":"https://api.github.com/users/henri-tremblay/repos","events_url":"https://api.github.com/users/henri-tremblay/events{/privacy}","received_events_url":"https://api.github.com/users/henri-tremblay/received_events","type":"User","site_admin":false},"assignees":[{"login":"henri-tremblay","id":1216819,"avatar_url":"https://avatars.githubusercontent.com/u/1216819?v=3","gravatar_id":"","url":"https://api.github.com/users/henri-tremblay","html_url":"https://github.com/henri-tremblay","followers_url":"https://api.github.com/users/henri-tremblay/followers","following_url":"https://api.github.com/users/henri-tremblay/following{/other_user}","gists_url":"https://api.github.com/users/henri-tremblay/gists{/gist_id}","starred_url":"https://api.github.com/users/henri-tremblay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henri-tremblay/subscriptions","organizations_url":"https://api.github.com/users/henri-tremblay/orgs","repos_url":"https://api.github.com/users/henri-tremblay/repos","events_url":"https://api.github.com/users/henri-tremblay/events{/privacy}","received_events_url":"https://api.github.com/users/henri-tremblay/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/ehcache/ehcache3/milestones/31","html_url":"https://github.com/ehcache/ehcache3/milestone/31","labels_url":"https://api.github.com/repos/ehcache/ehcache3/milestones/31/labels","id":2179084,"number":31,"title":"3.2.1","description":"","creator":{"login":"ljacomet","id":135308,"avatar_url":"https://avatars.githubusercontent.com/u/135308?v=3","gravatar_id":"","url":"https://api.github.com/users/ljacomet","html_url":"https://github.com/ljacomet","followers_url":"https://api.github.com/users/ljacomet/followers","following_url":"https://api.github.com/users/ljacomet/following{/other_user}","gists_url":"https://api.github.com/users/ljacomet/gists{/gist_id}","starred_url":"https://api.github.com/users/ljacomet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ljacomet/subscriptions","organizations_url":"https://api.github.com/users/ljacomet/orgs","repos_url":"https://api.github.com/users/ljacomet/repos","events_url":"https://api.github.com/users/ljacomet/events{/privacy}","received_events_url":"https://api.github.com/users/ljacomet/received_events","type":"User","site_admin":false},"open_issues":5,"closed_issues":1,"state":"open","created_at":"2016-12-06T15:11:31Z","updated_at":"2016-12-13T20:41:09Z","due_on":null,"closed_at":null},"comments":5,"created_at":"2016-10-03T13:53:20Z","updated_at":"2016-12-13T20:44:06Z","closed_at":null,"body":"Tested on Ehcache 3.1.2 and 3.2.0-SNAPSHOT\n\nRunning this code :\n\n```\n\nimport org.ehcache.Cache;\nimport org.ehcache.CacheManager;\nimport org.ehcache.config.builders.CacheManagerBuilder;\nimport org.ehcache.config.units.EntryUnit;\nimport org.testng.annotations.Test;\n\nimport static org.ehcache.config.builders.CacheConfigurationBuilder.newCacheConfigurationBuilder;\nimport static org.ehcache.config.builders.CacheManagerBuilder.newCacheManagerBuilder;\nimport static org.ehcache.config.builders.ResourcePoolsBuilder.newResourcePoolsBuilder;\nimport static org.ehcache.config.units.MemoryUnit.MB;\n\npublic class OffheapAllocation {\n\n  @Test\n  public void testPool() {\n\n    for (int i = 0; i < 10; i++) {\n      CacheManagerBuilder cacheManagerBuilder = newCacheManagerBuilder();\n      CacheManager cacheManager = cacheManagerBuilder\n          .withCache(\"cache\", newCacheConfigurationBuilder(Long.class, byte[].class, newResourcePoolsBuilder()\n              .heap(1, EntryUnit.ENTRIES)\n              .offheap(2000, MB)\n              ).build())\n          .build(true);\n\n      Cache<Long, byte[]> cache = cacheManager.getCache(\"cache\", Long.class, byte[].class);\n      cache.put(1L, new byte[1000]);\n      cacheManager.close();\n    }\n  }\n\n}\n```\n\nWill cause an OutOfMemory error.\nFirst iteration in the loop will allocate around 2GB of Offheap but on subsequent iterations, the memory will lower down until there is not enough anymore to allocate Offheap and then throw the following exception:\n\n```\n1820 [main] WARN  o.t.o.p.UpfrontAllocatingPageSource - Attempting to allocate 2.4GB of offheap when there is only 776.4MB of free physical memory - some paging will therefore occur.\n1820 [main] DEBUG o.t.o.p.UpfrontAllocatingPageSource - Allocating 2.4GB in chunks\n2843 [main] DEBUG o.t.o.b.OffHeapBufferSource - Failed to allocate 1073741824 byte offheap buffer\njava.lang.OutOfMemoryError: Direct buffer memory\n    at java.nio.Bits.reserveMemory(Bits.java:658)\n    at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:123)\n    at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:311)\n    at org.terracotta.offheapstore.buffersource.OffHeapBufferSource.allocateBuffer(OffHeapBufferSource.java:36)\n    at org.terracotta.offheapstore.buffersource.TimingBufferSource.allocateBuffer(TimingBufferSource.java:45)\n    at org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource.allocateBackingBuffers(UpfrontAllocatingPageSource.java:464)\n    at org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource.<init>(UpfrontAllocatingPageSource.java:136)\n    at org.terracotta.offheapstore.paging.UpfrontAllocatingPageSource.<init>(UpfrontAllocatingPageSource.java:119)\n    at org.ehcache.impl.internal.store.offheap.OffHeapStore.createBackingMap(OffHeapStore.java:94)\n    at org.ehcache.impl.internal.store.offheap.OffHeapStore.access$500(OffHeapStore.java:65)\n    at org.ehcache.impl.internal.store.offheap.OffHeapStore$Provider.init(OffHeapStore.java:186)\n    at org.ehcache.impl.internal.store.offheap.OffHeapStore$Provider.initStore(OffHeapStore.java:182)\n    at org.ehcache.impl.internal.store.offheap.OffHeapStore$Provider.initAuthoritativeTier(OffHeapStore.java:212)\n    at org.ehcache.impl.internal.store.tiering.TieredStore$Provider.initStore(TieredStore.java:505)\n    at org.ehcache.core.EhcacheManager$8.init(EhcacheManager.java:496)\n    at org.ehcache.core.StatusTransitioner.runInitHooks(StatusTransitioner.java:135)\n    at org.ehcache.core.StatusTransitioner.access$000(StatusTransitioner.java:33)\n    at org.ehcache.core.StatusTransitioner$Transition.succeeded(StatusTransitioner.java:194)\n    at org.ehcache.core.Ehcache.init(Ehcache.java:582)\n    at org.ehcache.core.EhcacheManager.createCache(EhcacheManager.java:258)\n    at org.ehcache.core.EhcacheManager.init(EhcacheManager.java:564)\n    at org.ehcache.config.builders.CacheManagerBuilder.build(CacheManagerBuilder.java:72)\n```"},"comment":{"url":"https://api.github.com/repos/ehcache/ehcache3/issues/comments/266856236","html_url":"https://github.com/ehcache/ehcache3/issues/1477#issuecomment-266856236","issue_url":"https://api.github.com/repos/ehcache/ehcache3/issues/1477","id":266856236,"user":{"login":"henri-tremblay","id":1216819,"avatar_url":"https://avatars.githubusercontent.com/u/1216819?v=3","gravatar_id":"","url":"https://api.github.com/users/henri-tremblay","html_url":"https://github.com/henri-tremblay","followers_url":"https://api.github.com/users/henri-tremblay/followers","following_url":"https://api.github.com/users/henri-tremblay/following{/other_user}","gists_url":"https://api.github.com/users/henri-tremblay/gists{/gist_id}","starred_url":"https://api.github.com/users/henri-tremblay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henri-tremblay/subscriptions","organizations_url":"https://api.github.com/users/henri-tremblay/orgs","repos_url":"https://api.github.com/users/henri-tremblay/repos","events_url":"https://api.github.com/users/henri-tremblay/events{/privacy}","received_events_url":"https://api.github.com/users/henri-tremblay/received_events","type":"User","site_admin":false},"created_at":"2016-12-13T20:44:06Z","updated_at":"2016-12-13T20:44:06Z","body":"I just retried now that #1328 is closed.\r\n\r\nI can't reproduce this issue exactly. I tried multiple JVM. The Hotspot behaviour is to trigger a full GC when going out of offheap memory. This will free some space. So it is slow but it never goes in OOME. You might have used a buggy JVM.\r\n\r\nHowever, I still see a memory leak, albeit a slow one, in PassThroughStatistic. So I will address it."}}
{"actor":{"display_login":"henri-tremblay"}}