Any suggestions for reducing client memory?

Hello guys, I’m not entirely sure if this is the appropriate place to put this but I wasn’t sure where else to post it.

I have been having some big problems with lag on my game and I could not figure out why, until I went into the developer console and the performance stats menu and saw this. I don’t entirely understand it so I would appreciate some help with figuring out how to fix it. Also, please let me know if I need to provide any more information.

MemoryIssuePt1

3 Likes

I’m assuming when you say lag, you mean FPS drops or low FPS in general. 400 MB of memory is not necessarily very high - many games run at over 1000MB without too many issues (Phantom Forces being one).

In my experience, you’re going to have better luck pinpointing lag by utilizing the Microprofiler. You can figure out exactly what is causing your FPS related issues using this tool.

If you can’t figure it out, take a look into generating a Microprofiler dump and upload it here, I, or somebody can help you analyze it.

1 Like

Thanks for your help, I have no idea how to use the Microprofiler, so here’s the HTML file that it made.

log_06372_microprofile_20190510-232953.html (691.2 KB)

Zooming into the dump file, you will see a long green bar labeled TweenService & UI Layout. It’s taking nearly 3ms to process the functions related to that. I’m not sure if UI Layout will include BillboardGUI rendering, but I’ve got a hunch that it does.

Does you game have a lot of BillboardGUI objects? Are you using TweenService or :TweenPosition/TweenSizeAndPosition inside of a Heartbeat call?

2 Likes

I have maybe 7 or 8 BillboardGUI objects, and how do I know if I am using Tweening inside of a heartbeat call?

7 or 8 BillboardGUIs shouldnt be causing any real lag, but if they’re all set to AlwaysOnTop with an infinite MaxDistance, it would be worth giving them a shorter MaxDistance. I don’t think that’s your problem, though.

Check your scripts. Try this:

  1. CTRL + Shift + F → “Tween”
  2. See if there’s any results in the Find Results window that pops up. Tweening in general is not bad however if something is Tweening every frame, you may have issues.
  3. If there’s results, see if there’s any way they can optimized. If you aren’t sure, feel free to post the code snippet(s) here and we can see if they are a problem.
1 Like

I have quite a bit of tweens on the client side, but they only tween when called so I don’t think that’s the problem.

Here’s really the only Tween I have that is done constantly, and it’s done on the server side, and I have about 8 or so scripts that do the same thing. This script makes something enlarge and then go smaller constantly every 6 seconds. This script isn’t necessary, so if you think this is causing the issue, it wouldn’t be that big of an issue to remove it.

Tweening on the server shouldn’t cause client FPS lag, however will cause server/latency issues. On the other hand, If there’s 8 scripts tweening two objects each every 6 seconds, with a tween time of 6 seconds, that’s 16 objects that are constantly being tweened, and as such replicating changes constantly to the client. This could cause FPS lag, especially on lower end devices.

There’s only one way to find out. Start disabling things one by one until your issues disappears. It’s all a process of elimination with this kind of thing.

2 Likes

It’s hard to test for me though since I’m not the one experiencing the lag issue, the issues are mostly on lower end devices and for some reason the Xbox One has bad lag issues. Thanks for the help though and I’ll see if I can figure it out.

Ah, understood. If you can’t directly test the issue - your best bet is to work on optimizing the game in general. Start with taking those tweens off the server, and putting them on the client.

It may sound counter-intuitive at first to handle everything like that on the client, however it makes it very easy to optimize. Whenever the client decides its time to perform an effect (tween, explosion, projectile movement, etc), simply check if the target instance (part, model, etc) is on the screen. This function will help with that.. If it’s not on the screen or is too many studs away from the camera - just simple don’t perform the effect.

6 Likes

Alright, thank you for your help!

1 Like

Someone told me about looping the tweens in a strange method, I haven’t tested it myself:
local info = TweenInfo.new(6, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, -1)

2 Likes

Not a strange method, this is documented.

The correct way to make a tween play indefinitely is to set RepeatCount to -1. Developers should avoid using large numbers (or math.huge) as a substitute as this is unstable and may stop working at any point.

6 Likes