YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
11 stars 4 forks source link

iOS RAM Usage inaccuracy #5649

Closed shichen85 closed 1 week ago

shichen85 commented 1 week ago

Description

For a blank project for iOS export, when using the debug_event("DumpMemory", true) function to assess memory usage, the number is much smaller compared to what we see from XCode.

Can debug_event() show a closer number to the actual memory usage?

Steps To Reproduce

  1. Compile the sample for iOS export
  2. See that debug_event() show the memory usage is only about 15 MB, but the XCode memory view shows the app is using about 150 MB

Which version of GameMaker are you reporting this issue for?

IDE v2024.200.0.499 Runtime v2024.200.0.516

Which operating system(s) are you seeing the problem on?

Windows 10.0.22000.0

24b78d08-5f81-4a45-9741-cc84edbb1cd4

time-killer-games commented 1 week ago

A small note for YoYoGames, it should just be a matter of:

  long long currprocram = -1;
  struct proc_taskallinfo info;
  if (proc_pidinfo(getpid(), PROC_PIDTASKALLINFO, 0, &info, sizeof(struct proc_taskallinfo)) > 0) {
    currprocram = (long long)info.ptinfo.pti_resident_size;
  }
  return currprocram;

...to get the amount of used RAM for the current process.

Just tried it on my end, and it gave the following:

Total memory used = 16606256 (0x00fd6430) bytes 15.84MB
Free memory = 7390048 (0x0070c360) bytes 7.05MB
Peak memory used = 773857440 (0x2e2020a0) bytes 738.01MB
foobar: 95.33 MB

With 'foobar' being the amount of MB returned by the C code at the top of this comment.

I'm not sure how GM calculates 'Total memory used' but it definitely seems a bit off.

stuckie commented 1 week ago

This is showing the memory that we are in control of; the operating system may be adding extra overhead which we can't track in a platform agnostic manner.