• 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
Question by MileSplit · Feb 27, 2014 at 11:09 PM · errorruntimememory

OutOfMemoryException: Out of memory

Im getting this weird error whenever I run my game, a google search reveals nothing specific to unity. Does anyone know what this runtime error is or how to fix it?

EDIT im now getting it every update and when i compile my script, how do i get rid of this? there is almost no textures on the screen and i am getting ~300 fps! Thanks!

Comment
ckaroun

People who like this

1 Show 0
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

3 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by MileSplit · Feb 28, 2014 at 03:35 AM

My problem ended up that i had too large of an array, it was

 public Vector3[,,,] tooLargeOfAnArray = new Vector3[50,50,1000,1000];

Because of this, the compiler could not initialize it all so it told me it ran out of memory, then every time i referenced tooLargeOfAnArray it ran out of memory and told me.

Comment

People who like this

0 Show 0 · 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

Answer by Anxo · Feb 27, 2014 at 11:17 PM

If you are using a lot of textures this may happen. It might not have much to do with your actually ram but more with the limited ram it is allowed to use. In an effort to avoid this, You can dump your textures in a resources folder and load them as needed instead of having them in the scene. That allows you to dump them from memory when they are no longer in use which becomes much more memory efficient.

Resource.Load https://docs.unity3d.com/Documentation/ScriptReference/Resources.Load.html

Resource.UnloadAsset https://docs.unity3d.com/Documentation/ScriptReference/Resources.UnloadAsset.html

Comment
ckaroun

People who like this

1 Show 0 · 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

Answer by ChrisSch · Feb 27, 2014 at 11:20 PM

OutOfMemoryException error means you've ran out of your free RAM memory, and the game usually crashes. So if you have 2gb of free memory it happens when it fills up those 2gb and the game crashes cause it needs more. Like my modded Skyrim and Minecraft. xD

Does it happen in every scene (new scene) or just on the current one you're working with? Assuming its the latter, and not Unity's fault, then you have something seriously filling up your free memory. That's all I can tell you with that much info.

Comment

People who like this

0 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 ChrisSch · Feb 27, 2014 at 11:32 PM 0
Share

Ah, yes that could be it. I'm also working on a procedural dungeon generation and have had bugs where it generates to infinity, but never had that error, it just froze up Unity after a good number of torch/chest filled dungeon rooms. xD

Probably cause I never built and ran it while it was bugged.

avatar image MileSplit · Feb 27, 2014 at 11:58 PM 0
Share

I just noticed this and i was wondering if somone could help, i get this error when i play AND once my code finishes compiling, but it doesn't stop me from playing...

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

23 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

Related Questions

Occlussion culling baking error?? 0 Answers

NaN exception when spawning soldiers 1 Answer

WebGl build on Server has load memory error 6 Answers

Light Changes when I run or build my scene 0 Answers

Help with changing spririterenderer's sprite 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges