267
votes

GC Spikes caused by OnGUI

GUI

-

-

The "Garbage Collector" spikes caused by using Unity's native GUI system causes (often massive) performance losses. There are numerous threads in the forums that document this:

http://forum.unity3d.com/threads/60217
http://forum.unity3d.com/threads/76937
http://forum.unity3d.com/threads/66689
http://forum.unity3d.com/threads/39868

Please fix or replace this!

Comments (10)

296aa498313701728be36b4a084e3152?d=mm
oegono
Nov 28, 2011 12:48

Please fix this problem.

4638f682ea9187f9cdf1200e793b661e?d=mm
Asse
Sep 16, 2011 11:41

Do it. Now!

6c3b1ecba93d134ad15c7dc3b8999fd5?d=mm
BDev
Aug 18, 2011 01:15

Its definitely annoying how much memory GUI uses that is collected. but in reality, while OnGUI stuff does add to the gc heap it should be noted that GC.Collect can happen anywhere, GUI does not manually collect the garbage. If you have any function that allocates something that can be garbage collected you will see GC.Collect show up there sometimes.

With that said though the GUI system should definitely use less gc heap memory, via using structs or native allocations. But GC Spikes in general are unavoidable, it just so happens if you are not using classes outside of components and scriptable objects which are not garbage collected it mainly happens in the GUI functions.

66822b21413c5e011617ce48377c5005?d=mm
sonicviz
Aug 12, 2011 03:12

Hey, Look, I love Unity and all...but it's pathetic that such a key area like GUI is so performance constrained. Waiting on 3.5 (maybe it will be in maybe not?) is really unacceptable. This area needs to be Priority 1.

2f0628578f5f164afe072d7483b82f72?d=mm
bigkahuna
Jul 29, 2011 11:43

Hopefully we'll see a fix for this with 3.5?

A957a41604b3103521da6bbadcc19d28?d=mm
Almar
Jul 29, 2011 11:38

This issue needs some serious attention, as it makes games quite choppy on some occasions, sometimes it happens once every second...

46d8b20212a5520b602ca850597fa192?d=mm
Packetburner
Jul 29, 2011 00:07

Although i knew it was an issue i am somewhat suprised how drastically the fps is eaten on displaying one window, i went from 400 fps to 6fps and have stripped the bare code out for testing with little improvement.

Please unity burn this evil bit of GUI and amalgamate some of the community versions with some Unity polish :)

46d8b20212a5520b602ca850597fa192?d=mm
Packetburner
Jul 29, 2011 00:07

Although i knew it was an issue i am somewhat suprised how drastically the fps is eaten on displaying one window, i went from 400 fps to 6fps and have stripped the bare code out for testing with little improvement.

Please unity burn this evil bit of GUI and amalgamate some of the community versions with some Unity polish :)

88b87698be0bc461f3cacf1f080929d5?d=mm
user
Jun 08, 2011 14:36

No Texture memory available to upload

2333916604f27cfe06e0289e417c3c96?d=mm
Zergling103
May 30, 2011 22:49

They should have just made GUI objects as Monobehaviors, which could be inherited from, parented to other GUI objects, etc. :/