Author Topic: 110-160mb mem usage??  (Read 1141 times)

Offline 9kaywun

  • byte
  • *
  • Posts: 20
  • Java Programmer
    • View Profile
110-160mb mem usage??
« on: October 24, 2012, 02:19:05 am »
I've been working on a multiplayer game using jPCT for quite some time now.. and it's been a very long work in progress. Lately I've done a full client/protocol optimization because I have an ETA set in December to publish it on my website. This is the most time consuming and long term application I have probably developed, and no code should be considered unstable or not efficient.

To the point here.. I am not sure why, but I cannot get memory usage to a satisfying level. Are there any common jPCT high memory solution techniques? So far my game consists of a plane, 5 animated npcs, a local player, and a 2nd user connected for most testing, and even when it's only the local player I have this issue.

Another note: Frames per second is between 55-60 usually, but memory is still way up there..

Edit: I ran VisualVM and apparently 117mb of memory is being used by int[] (has to be jPCT, maybe I am not doing something as intended, ie: vector usage?)

Edit 2: Even the login state (no world/object3d instances, just 2 and 4 lines of text) has the same issue with memory usage.
« Last Edit: October 24, 2012, 03:22:28 am by 9kaywun »
Developing a 3D multiplayer engine using jPCT:
Deleted, will return soon..

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: 110-160mb mem usage??
« Reply #1 on: October 24, 2012, 08:47:29 am »
I somehow fail to see the actual issue here...how much of the ~150mb do the actual int[]s consume? And how much is overhead caused by the VM itself? You have to keep in mind that the VM will always reserve/consume quite a few MBs for it's own purpose. 150mb isn't much for todays machines and not a problem by itself IMHO.
Anyway, the only int[]-array in existence before creating a world/objects is the one used by the FrameBuffer to backup the screen. You might want to log memory usage before and after creating that buffer to see if that's causing it.
Apart from that, you can do different things on the object level:


Offline 9kaywun

  • byte
  • *
  • Posts: 20
  • Java Programmer
    • View Profile
Re: 110-160mb mem usage??
« Reply #2 on: October 24, 2012, 10:18:33 am »

Pic^

Compression not necessary as I am using MD2 format models, stripping makes the entities not visible, and max polys visible is only 9000 at the moment.

When I force a garbage collection using VisualVM, memory drops to 80-90mb.. Then climbs at bounces around at 120-140mb.

Also, out of curiosity I tried this.. and if I stick Runtime.getRuntime().gc() into my fps check (called every 1000ms) it stays between 79-90mb.. I never call a gc request in a cycle, but in this case it seems to help dramatically.

Thoughts?
« Last Edit: October 24, 2012, 10:30:06 am by 9kaywun »
Developing a 3D multiplayer engine using jPCT:
Deleted, will return soon..

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11748
    • View Profile
    • http://www.jpct.net
Re: 110-160mb mem usage??
« Reply #3 on: October 24, 2012, 10:37:36 am »
Thoughts?
Yes, don't bother with it. The VM manages it's memory on its own and calls the gc whenever it thinks it has to. There's no point in calling gc by yourself just to free some of the VMs internal memory. The VM reserves memory to use it and there's no need to worry about that it actually does.

Offline 9kaywun

  • byte
  • *
  • Posts: 20
  • Java Programmer
    • View Profile
Re: 110-160mb mem usage??
« Reply #4 on: October 24, 2012, 11:09:25 am »
Alrighty. Thanks ;)
Developing a 3D multiplayer engine using jPCT:
Deleted, will return soon..