• 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
1
Question by fahimalavi · May 17, 2015 at 07:20 AM · texturememoryhang

Huge memory consumption even on windows

I have made a game when running on (PC) it is consuming about 219,500K memory when I see in windows task manager. Game is hanging and lagging a bit as well. Seems memory consumption problem. exe is just about 17 mb. I am worried as it is my first scene and haven't ported yet it on small devices i.e. iphone/Android

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by tanoshimi · May 17, 2015 at 07:21 AM

Memory usage is completely unrelated to .exe size - you can cause a memory overflow with a single-line infinite loop.... You need to use the profiler to see what's going on.

Comment
Add comment · Show 3 · 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 fahimalavi · May 17, 2015 at 09:55 AM 0
Share

I just used profiler.GetRuntimeMemorySize to get the size of textures in use. I noticed it is 53 MB :(. But still I have 150 MB of unknown things. My character size is about 280 bytes. I am generating a prefab continously after every 30 seconds also about 280 Bytes(too small). Am I missing anything ?

avatar image Bunny83 · May 17, 2015 at 11:46 AM 1
Share

@fahimalavi: Yes you probably miss something ^^

btw the size of the exe file is constant. When you create a build absolutely nothing is changed on the exe. The exe is just the UnityEngine. It's a playback engine for your game. Your actual game data is in the _Data folder next to the exe file ^^.

Also keep in mind that Unity uses a managed environment. Usually once the Mono engine has requested system memory it does not necessarily free the system memory if it's no longer in use. From the managed point of view the memory is "free" so the managed memory manager can use this memory if needed. The memory usage you see in the TaskManager doesn't say anything about the actual usage.

Try System.GC.GetTotalMemory(false). If you use System.GC.GetTotalMemory(true) the garbage collector collects all garbage before calculating the used memory. Since there's always some garbage waiting to be collected with "true" the size will be smaller. However if you average the values returned by System.GC.GetTotalMemory(false) over a period of time you get a more realistic value.

avatar image fahimalavi · May 17, 2015 at 02:53 PM 0
Share

@Bunny83 and @tanoshimi Thanks all, it found out to be 63 mb :) but game is still lagging. I need to look into CPU usage as well, optimizations and Profiling

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

2 People are following this question.

avatar image avatar image

Related Questions

Unity iOS memory usage 0 Answers

Lost texture in Android build 0 Answers

Assigning UV Map to model at runtime 0 Answers

Duplicate Texture Memory with Sprite Atlas 0 Answers

Compressed texture using same memory as uncompressed in run time? Please clear up. 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