High CPU and Memory Usage [?]

For questions about using Classic.

Post » Fri Jul 24, 2009 11:14 am

Here is the code for my entire .cap. There are three objects: two 32x32 sprites and one array object.

[url:3txowwbs]http://pub.gamingw.net/39880/procgen1.jpg[/url:3txowwbs]

As you can see there isn't much to it, but despite this I am getting fairly high CPU and memory usage from this.

With all events enabled.

29mb 13% - Linear
31mb 19% - Point

With the third event disabled (others enabled).

8mb 1% - Linear
11mb 1% - Point

With the second event disabled (others enabled).

13mb 3% - Linear
13mb 4% - Point

These numbers may not seem startling to you, but they do for me. My specs are an E8200 2.66GHz Core2Duo and an 8800GT 512mb. This problem becomes exponentially worse the more I add to it. I don't understand why it requires 30mb and 20% of the CPU when it isn't running any events. Unlimited framerate is disabled so it's not like it's rendering the screen a bajillion times a second or anything.

As it stands this would be unusable for me. Trying to create anything beyond simple applications would quickly tax my cpu and probably blow a ram chip out of the DIMM.

The version I am running is 98.9, so not an unstable release.
B
2
G
3
Posts: 68
Reputation: 986

Post » Fri Jul 24, 2009 11:54 am

Those events will run every tick, if you don't want them to, set a variable or use functions, so they only run once.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Fri Jul 24, 2009 12:06 pm

[quote="Rich":2cniamgh]Those events will run every tick, if you don't want them to, set a variable or use functions, so they only run once.[/quote:2cniamgh]

Then what is the purpose of "trigger once"?

EDIT: This seems to have helped. It reduced it to 5% and 18mb. This still seems somewhat high for a program that isn't really doing anything, but maybe that's just the nature of the beast.
B
2
G
3
Posts: 68
Reputation: 986

Post » Fri Jul 24, 2009 4:24 pm

[quote="Farmrush":1baw7jw8][quote="Rich":1baw7jw8]Those events will run every tick, if you don't want them to, set a variable or use functions, so they only run once.[/quote:1baw7jw8]

Then what is the purpose of "trigger once"?[/quote:1baw7jw8]

Yeah, I guess I'm not getting this either... a trigger once on it's own should literally only trigger once, yes?
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Fri Jul 24, 2009 9:42 pm

Should be:

Always
Trigger once
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Fri Jul 24, 2009 9:48 pm

[quote="Madster":13dcnc4g]Should be:

Always
Trigger once[/quote:13dcnc4g]

Could you explain that to me? Why is it setup like so?

I've changed to functions, though. Now if I could just get help figuring out where I went wrong with my events I'd be on my way, haha.
B
2
G
3
Posts: 68
Reputation: 986

Post » Fri Jul 24, 2009 10:28 pm

Trigger once's description reads "fires once while true"
Always is always true

so
Always
Trigger once

will fire once and then never again because Always will stay being true.
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Fri Jul 24, 2009 11:54 pm

'Always' generally has no effect when added to existing events. So:
Always
Trigger once
is identical to simply having
Trigger once
on its own.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Sat Jul 25, 2009 12:58 am

[quote="Ashley":seziym7e]'Always' generally has no effect when added to existing events. So:
Always
Trigger once
is identical to simply having
Trigger once
on its own.[/quote:seziym7e]

What does trigger once even do then?

Also, is it normal to still have 5-7% cpu usage even when your program is idling? I looked more carefully and memory usage still increases by about 4kb every couple seconds (relatively inconsequential for now, but if someone was playing a game for hours...). Nothing is even occurring in the program!

EDIT: I've done further testing and found that most other .caps that aren't extensive (I ran the zelda scrolling and some particle ones) only use up 0-1% CPU with, for example, particles bouncing all over the place and all sorts of calculations being done PER TICK. My program doesn't seem to be doing anything after it generates a layout (which it is still doing incorrectly), but uses 5% CPU? What??
B
2
G
3
Posts: 68
Reputation: 986

Post » Sat Jul 25, 2009 6:59 am

Trigger once is usually used in conjuction with another condition. For example:

[code:382s0g7h]+If 'variable' equals 0
+Trigger Once
-Add 1 to 'variable2'[/code:382s0g7h]
If the first condition comes out true, then the action within will only be performed once. However, if the first condition later evaluates to false, then the action will trigger again as soon as the first condition is once again true, starting the cycle over.

If you want the events under the trigger once conditions to only be run at the start of the layout, it would be better to put them as sub events to the start of layout condition.

EDIT: Here's an example showing what I just described.
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 8 guests