Metaspace is only increasing, not decreasing.

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

User avatar
khanhdev
Posts: 30
Joined: 24 Mar 2017, 11:32

Metaspace is only increasing, not decreasing.

Postby khanhdev » 14 Jun 2021, 03:07

Metaspace is only increasing, not decreasing. Running for 1 week will be full of memory. My game room is constantly being created and deleted.
Room creation configuration
cfg.setDynamic(true);
cfg.setAutoRemoveMode(SFSRoomRemoveMode.NEVER_REMOVE);
I remove the room using the method SmartFoxServer.getInstance().getAPIManager().getSFSApi().removeRoom(room) inside room extension class.
where did i go wrong?

Image
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Metaspace is only increasing, not decreasing.

Postby Lapo » 14 Jun 2021, 07:33

Hi,
at some point the metaspace should also be released. Although it's difficult to predict when, because the GC operates in mysterious ways :)

If there's a memory leak, usually it is because event/request listeners are not removed correctly when the Extension is released.
The one reason for this is that you implemented a custom destroy() method, but forgot to invoke the super.destroy() method.
In other words:

Code: Select all

@Ovveride
public void destroy()
{
   super.destroy();
   // ... custom code here ...
}


Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
khanhdev
Posts: 30
Joined: 24 Mar 2017, 11:32

Re: Metaspace is only increasing, not decreasing.

Postby khanhdev » 15 Jun 2021, 01:07

I don't implement a custom destroy() method.

The fact is that the GC is called but the metaspace is not cleaned up. after few days will throw exception java.lang.OutOfMemoryError: Compressed class space.

I am very tired about this problem. When a room is removed I see that the objects that follow it have been cleaned but the number of classes loaded has not decreased, leading to an increasingly large metaspace.
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Metaspace is only increasing, not decreasing.

Postby Lapo » 15 Jun 2021, 06:34

Hi,
you can deploy the Room Extension(s) under the extensions/__lib__/ to avoid the problem entirely.
See the documentation here:
http://docs2x.smartfoxserver.com/Extens ... assLoading

With this approach the Room Extension classes will be loaded by the top class loader.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
khanhdev
Posts: 30
Joined: 24 Mar 2017, 11:32

Re: Metaspace is only increasing, not decreasing.

Postby khanhdev » 15 Jun 2021, 08:44

Lapo wrote:Hi,
you can deploy the Room Extension(s) under the extensions/__lib__/ to avoid the problem entirely.
See the documentation here:
http://docs2x.smartfoxserver.com/Extens ... assLoading

With this approach the Room Extension classes will be loaded by the top class loader.

Cheers



Thanks Rapo! Hope I can fix this problem
kasjain25
Posts: 1
Joined: 29 Jun 2021, 14:28

Re: Metaspace is only increasing, not decreasing.

Postby kasjain25 » 29 Jun 2021, 14:30

I faced the same issue and tried everything. But at the end, the static instance of GSON object was the culprit. I was using it for serializing my object in toString method, I removed it and everything started working perfectly fine.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 43 guests