Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 rishiraw · Jan 19, 2016 at 09:21 PM · pluginpluginsc++memory-leak

Code requirements for C++ plugin in Unity

I have some working C++ code that I would like to pull into Unity3d.

I am able to compile a bundle in Xcode and have it show up in Unity3d. Dummy functions within the plugin (e.g. a function I wrote called "ReturnFour", a basic function that returns 4) work fine. However, when I try to execute more complex functions, I get memory leaks:

 Here's the output from the crash report:
 
 Crashed Thread:        0  CrBrowserMain  Dispatch queue: com.apple.main-thread
 
 Exception Type:        EXC_CRASH (SIGABRT)
 Exception Codes:       0x0000000000000000, 0x0000000000000000
 Exception Note:        EXC_CORPSE_NOTIFY
 
 Application Specific Information:
 abort() called
 *** error for object 0x12ba79b20: pointer being freed was not allocated
  
 
 Thread 0 Crashed:: CrBrowserMain  Dispatch queue: com.apple.main-thread
 0   libsystem_kernel.dylib            0x00007fff84a2f002 __pthread_kill + 10
 1   libsystem_pthread.dylib           0x00007fff807ac5c5 pthread_kill + 90
 2   libsystem_c.dylib                 0x00007fff8bdca6e7 abort + 129
 3   libmono.0.dylib                   0x0000000109ca4e0e mono_handle_native_sigsegv + 732
 4   libmono.0.dylib                   0x0000000109cec8ff 0x109c32000 + 764159
 5   libsystem_platform.dylib          0x00007fff80c88eaa _sigtramp + 26
 6   ???                               0x000000012573ae41 0 + 4923305537
 7   libsystem_c.dylib                 0x00007fff8bdca6e7 abort + 129
 8   libsystem_malloc.dylib            0x00007fff89ffd070 free + 425
 9   libstdc++.6.dylib                 0x00007fff82c23d1c std::string::_M_mutate(unsigned long, unsigned long, unsigned long) + 332
 10  libstdc++.6.dylib                 0x00007fff82c247be std::string::assign(char const*, unsigned long) + 78
 11  com.yourcompany.ASimplePlugin     0x000000012594357c BioFVM::Microenvironment::Microenvironment() + 936 (BioFVM_microenvironment.cpp:91)
 12  com.yourcompany.ASimplePlugin     0x000000012592f0a7 PrintFour + 37 (trial.cpp:30)



I guess it's possible that my code has memory leaks, but It's been extensively tested in the past and I don't think it does.

Is there some basic memory requirement/compilation tag that I need to respect to produce a bundle that plays well with U3D?

Comment
Add comment · Show 1
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 cjdev · Jan 20, 2016 at 12:19 AM 0
Share

According to that error message you're using a pointer that hasn't been instantiated yet. Are you sure you don't have one floating around from when you implemented the merge to Unity?

0 Replies

· Add your reply
  • Sort: 

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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Performance: C# vs C++ (plugin) 0 Answers

Making a plugin from an open source music language 0 Answers

Unity plugins 0 Answers

Detecting a word clicked on in 3D text? 1 Answer

Is there a way to create a C++ Managed DLL for Unity? 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