Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak in com.hazelcast.cache.impl.AbstractCacheRecordStore.batchEvent #6618

Closed
netudima opened this issue Oct 30, 2015 · 1 comment

Comments

Projects
None yet
4 participants
@netudima
Copy link

commented Oct 30, 2015

Nobody removes CacheEventData from batchEvent Map.
Test to reproduce:

public class App {
    public static void main( String[] args ) {
        System.setProperty("hazelcast.jcache.provider.type", "server");
        try(CachingProvider cachingProvider = Caching.getCachingProvider()) {
            CacheManager cacheManager = cachingProvider.getCacheManager();
            MutableConfiguration<String, Object> config = new MutableConfiguration<>();
            config.setStoreByValue(true)
                    .setTypes(String.class, Object.class)
                    .setStatisticsEnabled(false);

            String cacheName = "test";
            cacheManager.createCache(cacheName, config);
            Cache<String, Object> cache = cacheManager.getCache(cacheName, String.class, Object.class);


            final SimpleEntryListener<String, Object> listener = new SimpleEntryListener<>();
            MutableCacheEntryListenerConfiguration<String, Object> listenerConfiguration =
                    new MutableCacheEntryListenerConfiguration<>(
                            FactoryBuilder.factoryOf(listener), null, true, true);
            cache.registerCacheEntryListener(listenerConfiguration);


            long n = 10000000;

            for (long i = 0; i < n; i++) {
                cache.put("Hello World", new byte[100000]);
                cache.removeAll();
            }

        }
    }

    public static class SimpleEntryListener<K, V>
            implements CacheEntryListener<K, V>, Serializable {
    }

}
2015-10-30T20:55:50.211+0300: 0.181: [GC [PSYoungGen: 32745K->650K(37888K)] 32745K->650K(123392K), 0.0019885 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
2015-10-30T20:55:50.593+0300: 0.563: [GC [PSYoungGen: 33418K->2307K(38912K)] 33418K->2315K(124416K), 0.0047083 secs] [Times: user=0.06 sys=0.00, real=0.01 secs] 
2015-10-30T20:55:50.717+0300: 0.687: [GC [PSYoungGen: 36099K->1513K(38912K)] 36107K->1521K(124416K), 0.0030677 secs] [Times: user=0.05 sys=0.00, real=0.00 secs] 
2015-10-30T20:55:50.828+0300: 0.798: [GC [PSYoungGen: 35305K->1369K(38912K)] 35313K->1385K(124416K), 0.0027230 secs] [Times: user=0.06 sys=0.00, real=0.00 secs] 
2015-10-30T20:55:51.544+0300: 1.514: [GC [PSYoungGen: 35161K->2828K(36864K)] 35177K->2916K(122368K), 0.0068284 secs] [Times: user=0.03 sys=0.00, real=0.01 secs] 
2015-10-30T20:55:52.232+0300: 2.203: [GC [PSYoungGen: 36620K->3062K(33792K)] 36708K->7180K(119296K), 0.0113540 secs] [Times: user=0.00 sys=0.00, real=0.01 secs] 
2015-10-30T20:55:55.638+0300: 5.608: [GC [PSYoungGen: 33734K->6133K(36864K)] 37851K->12039K(122368K), 0.0190597 secs] [Times: user=0.05 sys=0.00, real=0.02 secs] 
2015-10-30T20:55:55.871+0300: 5.841: [GC [PSYoungGen: 36812K->5809K(33792K)] 42718K->11739K(119296K), 0.0100945 secs] [Times: user=0.00 sys=0.00, real=0.01 secs] 
2015-10-30T20:55:55.950+0300: 5.920: [GC [PSYoungGen: 32433K->5198K(35328K)] 38363K->13108K(120832K), 0.0142146 secs] [Times: user=0.02 sys=0.01, real=0.01 secs] 
2015-10-30T20:55:56.025+0300: 5.995: [GC [PSYoungGen: 31822K->1689K(35328K)] 39732K->13107K(120832K), 0.0040487 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] 
2015-10-30T20:55:56.098+0300: 6.069: [GC [PSYoungGen: 28296K->4358K(35328K)] 39714K->17273K(120832K), 0.0035055 secs] [Times: user=0.05 sys=0.00, real=0.00 secs] 
2015-10-30T20:55:56.227+0300: 6.197: [GC [PSYoungGen: 30933K->714K(35328K)] 43848K->14134K(120832K), 0.0211154 secs] [Times: user=0.05 sys=0.00, real=0.02 secs] 
2015-10-30T20:55:56.333+0300: 6.304: [GC [PSYoungGen: 27243K->4652K(35328K)] 40663K->18675K(120832K), 0.0046282 secs] [Times: user=0.02 sys=0.02, real=0.01 secs] 
2015-10-30T20:55:56.423+0300: 6.393: [GC [PSYoungGen: 31266K->1365K(34304K)] 45288K->15794K(119808K), 0.0221401 secs] [Times: user=0.06 sys=0.00, real=0.02 secs] 
2015-10-30T20:55:56.506+0300: 6.477: [GC [PSYoungGen: 27928K->1983K(34816K)] 42357K->16917K(120320K), 0.0171773 secs] [Times: user=0.06 sys=0.02, real=0.02 secs] 
2015-10-30T20:55:56.562+0300: 6.532: [GC [PSYoungGen: 28589K->1300K(35840K)] 43522K->16746K(121344K), 0.0153894 secs] [Times: user=0.05 sys=0.00, real=0.02 secs] 
2015-10-30T20:55:56.988+0300: 6.959: [GC [PSYoungGen: 28938K->421K(35840K)] 44384K->16265K(121344K), 0.2645542 secs] [Times: user=0.27 sys=0.00, real=0.27 secs] 
2015-10-30T20:55:57.285+0300: 7.255: [GC [PSYoungGen: 28069K->5336K(35840K)] 43913K->21490K(121344K), 0.0324040 secs] [Times: user=0.06 sys=0.00, real=0.03 secs] 
...

...
2015-10-30T20:58:21.256+0300: 151.216: [Full GC [PSYoungGen: 15326K->9035K(29696K)] [ParOldGen: 87004K->86907K(87040K)] 102331K->95942K(116736K) [PSPermGen: 20308K->20308K(21504K)], 0.0356001 secs] [Times: user=0.08 sys=0.00, real=0.04 secs] 
2015-10-30T20:58:21.295+0300: 151.255: [Full GC [PSYoungGen: 15286K->14612K(29696K)] [ParOldGen: 86907K->86907K(87040K)] 102193K->101519K(116736K) [PSPermGen: 20308K->20308K(21504K)], 0.0372488 secs] [Times: user=0.14 sys=0.00, real=0.04 secs] 
2015-10-30T20:58:21.333+0300: 151.293: [Full GC [PSYoungGen: 15309K->15296K(29696K)] [ParOldGen: 86907K->86907K(87040K)] 102216K->102203K(116736K) [PSPermGen: 20308K->20308K(21504K)], 0.0358111 secs] [Times: user=0.05 sys=0.00, real=0.04 secs] 
2015-10-30T20:58:21.369+0300: 151.329: [Full GC [PSYoungGen: 15298K->15297K(29696K)] [ParOldGen: 87004K->87004K(87040K)] 102303K->102301K(116736K) [PSPermGen: 20308K->20308K(21504K)], 0.0358864 secs] [Times: user=0.08 sys=0.00, real=0.04 secs] 
2015-10-30T20:58:21.405+0300: 151.365: [Full GC [PSYoungGen: 15297K->15297K(29696K)] [ParOldGen: 87004K->87004K(87040K)] 102301K->102301K(116736K) [PSPermGen: 20308K->20308K(21504K)], 0.0362426 secs] [Times: user=0.14 sys=0.00, real=0.04 secs] 
2015-10-30T20:58:21.443+0300: 151.403: [Full GC [PSYoungGen: 15328K->9132K(29696K)] [ParOldGen: 87004K->86907K(87040K)] 102333K->96039K(116736K) [PSPermGen: 20308K->20308K(21504K)], 0.0357496 secs] [Times: user=0.08 sys=0.00, real=0.04 secs] 
2015-10-30T20:58:21.483+0300: 151.443: [Full GC [PSYoungGen: 15320K->14807K(29696K)] [ParOldGen: 86907K->86907K(87040K)] 102227K->101714K(116736K) [PSPermGen: 20308K->20308K(21504K)], 0.0408740 secs] [Times: user=0.09 sys=0.00, real=0.04 secs] 
2015-10-30T20:58:21.524+0300: 151.484: [Full GC [PSYoungGen: 15302K->15296K(29696K)] [ParOldGen: 86907K->86907K(87040K)] 102209K->102203K(116736K) [PSPermGen: 20308K->20308K(21504K)], 0.0402871 secs] [Times: user=0.14 sys=0.00, real=0.04 secs] 
2015-10-30T20:58:21.565+0300: 151.525: [Full GC [PSYoungGen: 15298K->15264K(29696K)] [ParOldGen: 87036K->87036K(87040K)] 102334K->102300K(116736K) [PSPermGen: 20308K->20308K(21504K)], 0.0382630 secs] [Times: user=0.03 sys=0.00, real=0.04 secs] 
2015-10-30T20:58:21.603+0300: 151.563: [Full GC [PSYoungGen: 15264K->15264K(29696K)] [ParOldGen: 87036K->87036K(87040K)] 102300K->102300K(116736K) [PSPermGen: 20308K->20308K(21504K)], 0.0363133 secs] [Times: user=0.08 sys=0.00, real=0.04 secs] 
2015-10-30T20:58:21.640+0300: 151.600: [Full GC [PSYoungGen: 15264K->15264K(29696K)] [ParOldGen: 87036K->87036K(87040K)] 102300K->102300K(116736K) [PSPermGen: 20308K->20308K(21504K)], 0.0353202 secs] [Times: user=0.12 sys=0.00, real=0.03 secs] 
2015-10-30T20:58:21.676+0300: 151.636: [Full GC [PSYoungGen: 15264K->15264K(29696K)] [ParOldGen: 87036K->87036K(87040K)] 102300K->102300K(116736K) [PSPermGen: 20308K->20308K(21504K)], 0.0356722 secs] [Times: user=0.03 sys=0.00, real=0.03 secs] 
2015-10-30T20:58:21.764+0300: 151.724: [Full GC [PSYoungGen: 15356K->9036K(29696K)] [ParOldGen: 87036K->86906K(87040K)] 102392K->95943K(116736K) [PSPermGen: 20317K->20317K(21504K)], 0.0791072 secs] [Times: user=0.12 sys=0.00, real=0.08 secs] 
2015-10-30T20:58:21.846+0300: 151.806: [Full GC [PSYoungGen: 15347K->9082K(29696K)] [ParOldGen: 86906K->86906K(87040K)] 102254K->95989K(116736K) [PSPermGen: 20317K->20317K(21504K)], 0.0657651 secs] [Times: user=0.16 sys=0.00, real=0.07 secs] 
2015-10-30T20:58:21.915+0300: 151.875: [Full GC [PSYoungGen: 15332K->9094K(29696K)] [ParOldGen: 86906K->86906K(87040K)] 102238K->96001K(116736K) [PSPermGen: 20317K->20317K(21504K)], 0.0418637 secs] [Times: user=0.11 sys=0.00, real=0.04 secs] 
2015-10-30T20:58:21.960+0300: 151.920: [Full GC [PSYoungGen: 15314K->9103K(29696K)] [ParOldGen: 86906K->86906K(87040K)] 102220K->96010K(116736K) [PSPermGen: 20317K->20317K(21504K)], 0.0371837 secs] [Times: user=0.08 sys=0.00, real=0.04 secs] 
2015-10-30T20:58:22.000+0300: 151.960: [Full GC [PSYoungGen: 15330K->9111K(29696K)] [ParOldGen: 86906K->86906K(87040K)] 102237K->96018K(116736K) [PSPermGen: 20317K->20317K(21504K)], 0.0366668 secs] [Times: user=0.08 sys=0.00, real=0.04 secs] 
2015-10-30T20:58:22.040+0300: 152.000: [Full GC [PSYoungGen: 15315K->9118K(29696K)] [ParOldGen: 86906K->86906K(87040K)] 102222K->96024K(116736K) [PSPermGen: 20317K->20317K(21504K)], 0.0358041 secs] [Times: user=0.08 sys=0.00, real=0.04 secs] 
2015-10-30T20:58:22.134+0300: 152.094: [Full GC [PSYoungGen: 15360K->0K(29696K)] [ParOldGen: 86906K->3638K(53760K)] 102266K->3638K(83456K) [PSPermGen: 21339K->21339K(22528K)], 0.0757693 secs] [Times: user=0.22 sys=0.00, real=0.08 secs] 
Heap
 PSYoungGen      total 29696K, used 1353K [0x00000000fd500000, 0x0000000100000000, 0x0000000100000000)
  eden space 15360K, 8% used [0x00000000fd500000,0x00000000fd6526e8,0x00000000fe400000)
  from space 14336K, 0% used [0x00000000ff200000,0x00000000ff200000,0x0000000100000000)
  to   space 14336K, 0% used [0x00000000fe400000,0x00000000fe400000,0x00000000ff200000)
 ParOldGen       total 53760K, used 3638K [0x00000000f8000000, 0x00000000fb480000, 0x00000000fd500000)
  object space 53760K, 6% used [0x00000000f8000000,0x00000000f838dad0,0x00000000fb480000)
 PSPermGen       total 22528K, used 21345K [0x00000000f2e00000, 0x00000000f4400000, 0x00000000f8000000)
  object space 22528K, 94% used [0x00000000f2e00000,0x00000000f42d8608,0x00000000f4400000)
@serkan-ozal

This comment has been minimized.

Copy link
Contributor

commented Oct 30, 2015

Thanks for reporting the issue @netudima Good finding 👍
AbstractCacheRecordStore::publishBatchedEvents should remove event set from batchEvent.

I mean instead of

final Set<CacheEventData> cacheEventDatas = batchEvent.get(cacheEventType);

it should be

final Set<CacheEventData> cacheEventDatas = batchEvent.remove(cacheEventType);

I will fix this ASAP.

@serkan-ozal serkan-ozal added this to the 3.6 milestone Oct 30, 2015

mustafaiman pushed a commit to mustafaiman/hazelcast that referenced this issue Nov 4, 2015

mustafaiman pushed a commit to mustafaiman/hazelcast that referenced this issue Nov 4, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.