Author Topic: JPCT eats so much CPU and Memory  (Read 5756 times)

Offline qjvictor

  • int
  • **
  • Posts: 77
    • View Profile
JPCT eats so much CPU and Memory
« on: December 09, 2006, 12:58:28 am »
We developed a game with web start, the problem is that it seems the jPCT takes so much cpu and memory.
I think it is not the problem caused by my code. because I access http://www.jpct.net/demos.html and click some very simple demos,
it also takes much cup and memory.

Anybody has solution for this issue?

Thanks.

Offline manumoi

  • long
  • ***
  • Posts: 121
    • View Profile
    • http://www.iro.umontreal.ca/~blanchae
JPCT eats so much CPU and Memory
« Reply #1 on: December 09, 2006, 07:55:55 pm »
Hello

what do you mean by "so much"? What is the complexity of your environment? And what renderer are you using?

Offline eye1

  • int
  • **
  • Posts: 68
    • View Profile
JPCT eats so much CPU and Memory
« Reply #2 on: December 11, 2006, 10:34:25 am »
Use sleep between renderings. I do rendering 25 times per minute and it only uses 2,3 percent of CPU (opengl mode)

Offline qjvictor

  • int
  • **
  • Posts: 77
    • View Profile
JPCT eats so much CPU and Memory
« Reply #3 on: December 11, 2006, 04:19:29 pm »
Thanks.
You mean in the loop to render the screen, use Thread.sleep?
I will try.
Thanks anyway.

Offline eye1

  • int
  • **
  • Posts: 68
    • View Profile
JPCT eats so much CPU and Memory
« Reply #4 on: December 11, 2006, 04:49:33 pm »
I use it like this

Code: [Select]

       //fps.. like 25
      int sleepTime = 1000 / fps;
      long first = System.currentTimeMillis();
      long second = 0;
      long actualSleepTime = 0;
      while (bRender) {
         //do some stuff in world here
         buffer.clear();
         world.renderScene(buffer);
         world.draw(buffer);
         buffer.update();
         buffer.displayGLOnly();
         second = System.currentTimeMillis();
         actualSleepTime = sleepTime - (second - first);
         if (actualSleepTime < 0) {
            actualSleepTime = 0;
         }
         try {
            Thread.sleep(actualSleepTime);
         }
         catch (InterruptedException ie) {}
         first=second;
      }



Offline qjvictor

  • int
  • **
  • Posts: 77
    • View Profile
JPCT eats so much CPU and Memory
« Reply #5 on: December 11, 2006, 08:13:08 pm »
The problem is that I must render the screen in every 10 ms.
Maybe that's the reason the jpct eats so much cpu.

Offline eye1

  • int
  • **
  • Posts: 68
    • View Profile
JPCT eats so much CPU and Memory
« Reply #6 on: December 11, 2006, 10:44:21 pm »
There can also be other reasons, like complex objects you are rendering (lot of polygons)...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
JPCT eats so much CPU and Memory
« Reply #7 on: December 12, 2006, 09:47:07 pm »
It eats up what you are giving to it. The demos are designed to run at full speed, which results in 100% cpu usage on a single core machine. If you don't want that, render less frames. As said, at a sleep if possible. And how much is much? You may try to use Config.saveMemory=true to save seom memory at the cost of...well, of almost nothing. Just try it and see if it helps.