• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by luniac · Nov 16, 2014 at 10:20 PM · audiopoolinggarbage collector

no instantiate/destroy but GC is still called!

Hi, i have implemented the poolmanager plugin in my android game and have 0 instantiate/destroy commands during gameplay, yet im always getting garbage collector calls once in awhile in the logcat internal profiler.

I'm suspecting it might have something to do with the sound, but i don't understand why, any object that uses audio has it's own sound source and the clips are referenced to variables on that object.

should i instead create 1 single universal AUDIO object that contains all my clips in variables and just play them by reference?

or maybe use poolmanager to create a pool of audiosources with any clip that i need and have object spawn whatever source they need at their location?

I can't think of what else might be causing the garbage collector to be called.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image luniac · Nov 16, 2014 at 10:32 PM 0
Share

wow even my main menu has GC calls, no gameplay at all just a couple of buttons... any Update() functions just check if some variable is == to something. No memory allocations other than on top of the script thats it!

avatar image luniac · Nov 16, 2014 at 11:07 PM 0
Share

is it possible that im just being OVERLY nitpicky about this?

Every few seconds i get max number of collection : 1 collection total duration : <10 all the time

so thats one single garbage call that lasts less than 10 ms called once every 3-4 seconds.

That's not so bad is it?

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Kiwasi · Nov 16, 2014 at 11:25 PM

GC works on every memory location that you no longer have a reference too. Instantiate and destroy are just called out as they are heavy producers of garbage. GC problems are typically noticeable in terms of occasional 'stutters' while playing the game. If no noticeable stutters then GC is not worth worrying about. The profiler will indicate the scripts that are producing the garbage, if you are overly concerned.

If its a finished game with performance problems then worry about GC. If its a half produced game that cannot be finished because of performance problems then worry about GC.

If your game has no performance issues, or you are worried that GC might be a problem later, then forget about it. Pre-optimisation generally causes more problems then it solves.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Kiwasi · Nov 16, 2014 at 11:25 PM 0
Share

The manual page on memory management is also a good place to check for GC details.

avatar image luniac · Nov 16, 2014 at 11:54 PM 0
Share

I'm using the free internal profiler which doesn't tell what scripts are producing garbage, unity free user here, thanks for the assist though.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

28 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

AudioSource.clip.time won't work? 2 Answers

Get the frequency from an AudioSource 1 Answer

Streaming Music Cause Copyright Issues? 3 Answers

Audio source no sound with spatial blend 3D 2 Answers

HOW TO VIBRATE CAMERA ACCORDING TO AUDIO BEATS ? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges