• 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 eem · Oct 31, 2011 at 09:22 PM · iosxcodeobjective

UnityCleanup()

I am attempting to load and unload Unity on demand within an iOS app. I have figured out how to load unity on demand. However I cannot figure out how to unload it. I noticed in the Objective C calls in AppController there is a 'UnityCleanup()' function that gets called in ApplicationWillTerminate function. And I assume that is what deallocates Unity from memory. But anytime I call that function from a button press in Objective C, it crashes.

Before I call UnityCleanup I have switched and MakeKeyAndVisible'd a viewController that is not Unity's. But it still crashes.

Has anyone attempted to do this? Is there anything I should before calling UnityCleanup? Any chain of things I need to clear references to or deallocate or something?

Comment
Add comment · Show 3
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 justbcuz · Apr 05, 2012 at 07:31 AM 1
Share

I am curious about this question too. Where you able to unload and dealloc the Unity instance on demand?

avatar image AndyMartin458 · Aug 01, 2013 at 10:15 PM 1
Share

I'm also curious about this.

avatar image Revolteh · Feb 28, 2018 at 08:15 AM 0
Share

The problem still exists in 2018.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by MartinCA · Aug 01, 2013 at 10:21 PM

Just taking a wild stab in the dark here, as I have zero experience with ObjC, but could this be a threading issue?

Are you executing this from the same thread that created the instance? Does the instance create new threads to run itself in? It could be an access violation caused if the engine is trying to update itself internally from it's own thread and you are calling Cleanup() which tries to free resources from a different thread.

Either way, some logs will really help out here :)

Comment
Add comment · Show 1 · 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 AndyMartin458 · Aug 01, 2013 at 10:57 PM 0
Share

I've looked at the logs, and our editor crashes a with this message. I'm not really sure what is happening, but maybe I should remove the call to UnityCleanup.

Unloading 2031 unused Assets to reduce memory usage. Loaded Objects now: 4089. Operation took 76.991829 ms.

System memory in use: 155.3 $$anonymous$$B. Receiving unhandled NULL exception Launching bug reporter

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

6 People are following this question.

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

Related Questions

Admob iOS integration with Xcode Version 6.3 1 Answer

"Culture name neutral is not supported" when using Parse.Unity.dll 2 Answers

iOS.RemoteNotification userInfo empty 2 Answers

Compile Error in XCode with Unity SplashScreenController/UnityViewControllerBase for IOS build 0 Answers

iOS Build Crash : task_set_exception_ports(B07, 400, D03, 0, 0) Error 0 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