Greetings!
Unity Pro 3.1.0f4, Win7 Home professional. Here’s some info on the machine I am running: http://forum.unity3d.com/threads/49995-Ultimate-Development-Rig. No other significant programs running, using only Microsoft Security Essentials for antivirus.
About 75% of the time when I play my game in the Unity editor on this machine, I get incredibly low framerates - even in GUI lobby scenes with practically no 3D elements. After a couple minutes of play, the problem occasionally disappears. The performance hit is variable, sometimes it is worse than other times. The same Unity project runs fine - the issue is nonexistent - in the Unity editor on my MacBook Pro.
I can play TF2 on this machine for hours on end with all settings maxed and get astounding framerates. I don’t think it is a hardware issue (though I did just turn down my overclocks - which didn’t help)…
I have tried tons of different things, but have yet to find a reliable way to reproduce this. Sometimes when I hit play the game is painfully slow (even audio playback stutters), and sometimes it runs like it should at well over 100 fps.
Here’s what the profiler looks like when the issue is at it’s worse (note that the inspector bar is over a spike in this shot, and the garbage collector is using an insane amount of resources):
http://picasaweb.google.com/aubreyfalconer/ScreenCaptures#5547768170860221394
And here’s what the profiler looks like when my game is running properly:
http://picasaweb.google.com/aubreyfalconer/ScreenCaptures#5548132744296517458
I have also noticed this issue in other Unity projects on my machine.
What could be going wrong? What else can I try? Has this bitten anyone else?
Thanks,
-Aubrey
P.S. The longer the editor runs, the less this issue appears. It’s like a reverse memory leak…
Extremely odd. I am wondering if it could be a virus. I have had some pretty messed up viruses before, so I wouldn’t be suprised if that was the problem. On the other hand, a reverse memory leak is odd.
Maybe try switching the affinity of the editor to see if that helps.
Your affinity suggestion was very interesting - I actually was able to stop the problem several times by changing the Unity Editor’s affinity from one processor to another. Unfortunately, no pattern emerged…
If you have any antivirus suggestions, I would be glad to give them a try! Being a longtime Mac user, the whole idea of one’s system suffering from debilitating virus attacks is somewhat foreign to me.
Here’s a very interesting video I just recorded:
Sorry for the pathetic quality, but it is the most dramatic illustration of the issue I have yet been able to capture. Just prior to the beginning of the recording, I had hit “play” in the Unity editor (just one of many times), and was greeted by unbelievably poor framerates (You can hear the stuttering audio, and see the first processor spiking in time with it on the display built into my keyboard). Note: When this is happening, the activity monitor shows the Unity editor as the only significant CPU user - it doesn’t seem like I have a rogue background process trashing everything. I switched to a more computationally intensive scene in my game by loading a map, and the issue almost immediately resolved itself (you can see the spikes in the Unity’s profiler graph level out). I then restarted the game in Unity, and the issue was completely gone even though it was the exact same scene that had brought the editor to it’s knees 15 seconds before. After the recording I restarted the game several more times, and the issue was present in varying degrees. Normally, switching scenes doesn’t solve the issue. The more the editor is challenged and the longer it has been running, the less frequent and severe the issue becomes.
Once we can figure out where the problem might be i’ll definitely file a big report - your suggestions and ideas are welcome!
So the affinity somewhat worked, well that was a semi-lucky guess then
.
Anyways, I would recommend avira antivirus. I don’t know about the paid version being worth it, but the free version has kept my computer virus clean… well, without any noticeable viruses for months. This is actually quite good, because I have a tendency to reinstall my OS every 2-3 months. I have heard AVG is good, but I have had bad experiences with it. I have heard Kaspersky is really good, but have not had a chance to test it. So, try avira.
Unity isn’t on the SSD, is it?
Yes Dreamora - is that a bad thing?
No, that it isn’t there is actually a good thing as unity writes many small files rather commonly and doing this on the ssd is definitely slower than on current 1TB+ harddisks with 32 to 64mb cache, independent of how fast the SSD is but especially if the SSD is that low performance on write speed.
What though can be a rather bad idea is leaving the profiler open when you do profiling, because its very impacting. you better keep it closed when profiling, then pause the game and open it for example. But that shouldn’t run this slow, my system is win7 64bit, core i7 920 and gtx280 and I’ve not the slightest problem.
Unsure to what degree the microsoft security impacts it as I don’t use it (I’ve been using ESET internet security for years)
I’ve got a somewhat similar situation (although not identical) to yours. I’m also running W7 Home Professional plus Microsoft Security Essentials on a nearly new i5 notebook. It seems (although I haven’t been able to confirm this) that MSE and Unity don’t seem to work well together. I frequently get write error messages, hard drive “dirty” flags and sometimes Unity either locks up or freezes momentarily. I only use this system for Unity, Photoshop and Blender but the problems only happen while I’m using Unity. I’ve checked my HD frequently and on every test it passes 100%. If I turn off the “real time” scanning for MSE the problem -almost- goes away (the only problem I get is an occasional HD dirty flag). I’ve contacted both M$oft and the notebook manufacturer and nobody seems to know what’s going on. I was using AVG but switched as it was just slowing my system down too much but I may have to go back to it or find another virus scanner. I googled for more info but haven’t found any reports that anyone else is having issues like this, so I’m just backing up my HD as often as I can and trying different things to see what may work.
I, too, have been using mostly Macs for the past 4 years so this is a new experience for me also. I love my new notebook but these virus protection apps are a real PITA. I wonder, if I were to disable the virus protection entirely and not use this computer for any browsing, and it’s behind a firewall, is my computer still at risk?
Sorry for the hijack, but your problem sounded similar enough to mine that I wondered whether yours might also be due to MSE?
As an idea: Assuming MSE allows that, I would recommend to do the same thing thats recommended for any realtime guard: Add the unity install folder and your project folder to the exclusions. you know they aren’t malicious, and unitys write pattern (a lot small files → metas) definitely isn’t supportive for any realtime guard.
See if this helps.
Forgot to mention that above but to me its naturally that any dev excludes such folders normally … guess might not hold for all.
All very interesting! I’ll switch to Avira, and report back tomorrow on whether it seems to have helped.
I have had the MSE real time scanning disabled ever since it was installed though, so it sure would be strange if simply having it on the computer turned out to be the problem.
@dreamora - Sorry I forgot to mention that I have already included the Unity folders (application and project folders) in the exclusion settings for MSE. That made things better (fewer write error messages) but still not 100%.
@robur - Actually, Avira is supposed to be worse for the problems I’m having. Google chckdsk and Avira together and you’ll find dozens of posts about the problem. Most people who have the problem are advised to switch to MSE! 
Wow! I thought I had disabled MSEs realtime monitoring - but I hadn’t. Now that my computer is “at risk”, Unity seems to be performing admirably.
Warning to all Unity devs: if your computer isn’t at risk, your sanity is!
I’ll post another update tomorrow once I have been able to observe my app’s performance more throughly. Thanks all for your ideas and suggestions.
Edit: Unreal… My cpu’s idle at 0.8% in my game’s lobby now instead of maxing an entire core. Could viruses really be that bad?
Sounds like MSE is extremely agressive on the access handling.
I recall that AVG Free is was the only monitor I’ve ever seen to be that agressive (aside of Norton Overprice Virus and McAfee System trasher naturally which aren’t worth the size of their installer due to the trouble you have as dev. they are for people barely able to press the energy button but really only for these users)
@robur - Well it’s somewhat comforting to know that I’m not the only one having this problem. I went through the MSE settings and, in addition to excluding the Unity app/project folders, I also excluded Unity.exe from the process exclusions. I’ve also got an open support ticket with M$oft regarding this. We’ll see what happens.
Could you try something and let me know what you find:
Open a command window (in the Accessories application folder in the Start menu) and launch it as an administrator (right click). Then in that window type “fsutil dirty query c:” and let me know what it says? What happens to me is that whenever I experience a pause in Unity the hard disk “Dirty” flag is triggered. I’m curious if the same thing is happening to you.
@dreamora - It seems that all the free virus scanners are too aggressive now a days. I’ve used AVG Free for years, but with the latest update (within the last month or two) it has become a resource hog to the point I couldn’t use it and get any work done. MSE was rated very highly but, as we’re now learning, doesn’t seem to play with Unity very well. I haven’t tried Avira, but have read that it also has issues with Windows 7.
I should also note that I have this problem with both Unity 3.1 and Unity 2.6.1, although it appears to be considerably worse with Unity 3.1. I wonder what AV software Unity Tech uses? Could someone there weigh in on this and perhaps recommend an AV we can use that won’t have these kinds of issues?
Aside from the well-known problem of Norton falsely picking Unity up as a virus (ie, you’ll inevitably have problems if you use it), the main advice from the team is just to make scanning exceptions for the project folder and for the Unity app folder. One of the testers recommends Comodo AV/Firewall as a system that seems to have no problems with Unity.
Can you tell us what AV software Unity Tech uses on their Windows 7 machines? That might help us find a fix for the situation we’re in.
@bigkahuna; So far, my c: drive has always reported non dirty - perhaps this is due to it being an ssd?
My Unity editor is still performing fantastically since disabling real time monitoring in MSE yesterday, so I am quite happy.