Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Allocation #140

Open
mesflores opened this issue Jan 17, 2019 · 2 comments
Open

Memory Allocation #140

mesflores opened this issue Jan 17, 2019 · 2 comments

Comments

@mesflores
Copy link
Contributor

Any recommendation, preferred examples, or documentation for managing dynamic memory allocation during simulation? I see some of the ROSS_models seem to use tw_calloc(), but I haven't found any description about its specific purpose or usage. Thanks!

@caitlinross
Copy link
Member

I don't think there's any documentation on that yet. Documentation is something I've been trying to work on as I get some time, but there's still a lot to do.

Basically we typically recommend not to use dynamically allocated memory, if you're using optimistic mode at all. In general, dynamic allocations can be slower, so that's why we pre-allocate our event buffers in ROSS during init. But for optimistic mode, you run into the additional problem of having to carefully choose when to free memory, because you need things to hang around in case of rollbacks. There's also technically a potential for any non-reversible library calls to cause issues in optimistic simulators, though I'm unsure how likely that is.

tw_calloc() is recommended over using actual dynamically created memory. This call will pull the memory from a memory pool. But there is no associated tw_free(), so you'd be responsible for figuring out how to manage the memory you get from the memory pool.

@mesflores
Copy link
Contributor Author

Thanks very much! Appreciate the guidance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants