Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question

Memory Leak?

I left an application with embedded Gigaspaces 5.2.2 running for a couple days and found that the memory keep increasing. So I dumped the memory heap and found that CacheEntryCell seems to hold references to all my keys and subsequently my values. Is it a known problem?

     Mem     Count         Class
0.4% 636k    16303   +636k com/j_spaces/map/eviction/Chain$CacheEntryCell
0.3% 429k    13758   +429k com/j_spaces/core/client/version/map/MapEntryInfoKey

This thread was imported from the previous forum.
For your reference, the original is available here

asked 2007-08-15 16:23:03 -0500

testy gravatar image

updated 2013-08-08 09:52:00 -0500

jaissefsfex gravatar image
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

This is interesting. We are not aware such an issue. We will check this with 5.2. Have you checked this with 6.0? Are you running Map API local cache or Map API embedded space?


answered 2007-08-16 13:42:05 -0500

shay hassidim gravatar image
edit flag offensive delete link more

BTW, when I dump the heap, I have only 10 items alive in the cache. However, thousands of different items have been put into the space previously and expired.

answered 2007-08-16 07:55:00 -0500

testy gravatar image
edit flag offensive delete link more


It's a embedded space.

testy gravatar image testy  ( 2007-08-16 19:46:00 -0500 )edit

Can you post your test application? Have you test this with 6.0?


shay hassidim gravatar image shay hassidim  ( 2007-08-18 12:22:04 -0500 )edit

I just checked with 6.0. It's reproducible there as well. It looks like there is a leak in CacheEntryCell object in Map implementation.

testy gravatar image testy  ( 2007-08-22 15:30:02 -0500 )edit

In 5.2.2, I was able to run it to the point where I got the exception:

Caused by: com.j_spaces.core.client.CacheException: Memory shortage in space: MyCache_DCache at com.j_spaces.core.client.cache.map.MapCache.internalGet(SourceFile:688) at com.j_spaces.map.AbstractMap.get(SourceFile:264) at com.j_spaces.map.AbstractMap.get(SourceFile:257)

Caused by: Memory shortage in space: singleCdsCache_DCache at com.j_spaces.obf.io.a(SourceFile:230) at com.j_spaces.obf.io.a(SourceFile:12) at com.j_spaces.obf.bw.b(SourceFile:437) at com.j_spaces.obf.bw.run(SourceFile:330)

After that, the memory threshold I set seems to kick itself in and it seems to be fine afterward. There are two points I would like to make: 1. If the entry is expired, it should not be referenced in memory anymore 2. When it doesn't have enough memory for cache, it should not throw exception first. It should try to clean itself up and only throw an exception when there is really no memory available for the operation.


testy gravatar image testy  ( 2007-08-23 09:10:03 -0500 )edit


You can try the following code. You can see that the map is pretty empty but you will get the exception shortly if your heap space is small.

{code} public void testLeak() throws Exception { IMap map = (IMap) CacheFinder.find("/./testCache?schema=mycache&versioned=false&create=true&noCache=false"); for (int i = 0; i < 1000000; i++) { map.put(i, i, 1); if (i%1000==0) { System.out.println(map.size()); Thread.sleep(10); } } }{code}

{quote}com.j_spaces.core.client.CacheException: Memory shortage in space: testCache at com.j_spaces.map.GSMapImpl.internalPut(SourceFile:169) at com.j_spaces.map.AbstractMap.put(SourceFile:246) at com.j_spaces.map.AbstractMap.put(SourceFile:225)

Caused by: Memory shortage in space: testCache at com.j_spaces.obf.io.a(SourceFile:247) at com.j_spaces.obf.io.w(SourceFile:204) at com.j_spaces.core.JSpaceImpl.a(SourceFile:1710) at com.j_spaces.core.JSpaceImpl.update(SourceFile:1633) at com.j_spaces.core.lrmi.LRMIRemoteSpaceImpl.update(SourceFile:250) at com.j_spaces.core.client.single.action.AbstractSingleSpaceUpdateActionListener.internalUpdate(SourceFile:97) at com.j_spaces.core.client.single.action.AbstractSingleSpaceUpdateActionListener.update(SourceFile:49) at com.j_spaces.core.client.single.action.SingleSpaceUpdateActionListener.onAction(SourceFile:15) at com.j_spaces.core.client.single.action.SingleSpaceUpdateActionListener.onAction(SourceFile:9) at com.j_spaces.core.client.AbstractSpaceProxy.update(SourceFile:483) at com.j_spaces.core.client.AbstractSpaceProxy.update(SourceFile:461) at com.j_spaces.map.GSMapImpl.internalPut(SourceFile:142) ... 24 more{quote}

testy gravatar image testy  ( 2007-08-23 15:50:04 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2007-08-15 16:23:03 -0500

Seen: 152 times

Last updated: Aug 16 '07