• 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 /
This question was closed Jun 28, 2021 at 08:26 AM by andrew-lukasik for the following reason:

Question is off-topic or not relevant

avatar image
0
Question by viseztrance · Jun 20, 2021 at 08:20 PM · dots

Can NativeList be used outside jobs?

As the title says, can native collections be used outside jobs safely as an alternative to pooling in order to avoid some gc allocations?


For example, can non persistent entries be deallocated before I have the chance to call dispose?

As for pooling and gc, I'm using lists for certain algorithms and given these have an arbitrary size, they create garbage every time I call Add. Pooling is creating these lists beforehand to reuse.

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

2 Replies

  • Sort: 
avatar image
0
Best Answer

Answer by viseztrance · Jun 27, 2021 at 09:13 PM

Can be closed. I ended up writing a native plugin in rust.

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

Answer by andrew-lukasik · Jun 20, 2021 at 09:29 PM

Please define "safely", "pooling" and expand on gc allocation sources.

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 viseztrance · Jun 21, 2021 at 12:33 AM 0
Share

For example, can non persistent entries be deallocated before I have the chance to call dispose?

As for pooling and gc, I'm using lists for certain algorithms and given these have an arbitrary size, they create garbage every time I call Add. Pooling is creating these lists beforehand to reuse.

avatar image andrew-lukasik viseztrance · Jun 21, 2021 at 07:45 AM 0
Share

can non-persistent entries be deallocated before I have the chance to call dispose?

Temp allocation has a lifespan of 1 frame and TempJob has lifespan of 4 frames. After that this memory is considered released (some containers throw lifespan warnings here). So, when using those allocators, make sure your jobs cannot run longer that their allocation allows.

Why are you asking this question? There must be more to this story, an error message or error result maybe?

avatar image andrew-lukasik viseztrance · Jun 21, 2021 at 07:59 AM 0
Share

they (lists) create garbage every time I call Add

This is not true. Lists allocate memory only when their capacity is reached.

As for pooling and gc (...)

NativeList does not involve GC, that is the point of NativeContainers.

Pooling is creating these lists beforehand to reuse.

The difference behind Persistent and Temp / TempJob allocators is that temp memory uses efficient internal pooling system and Persistent does not. Inventing another pooling system for Temp / TempJob is ungrounded.

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

120 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

I'm not seeing a performance increase with the Job System. Help 1 Answer

Jobs perfomance slower than single thread. 2 Answers

Get GameObject dependencies only once for JobComponentSystem 1 Answer

Can the burst compiler be used for any code? 0 Answers

Does DOTS have a animation component? 1 Answer


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