Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Mastering Oculus Rift Development

You're reading from   Mastering Oculus Rift Development The next frontier of gaming and simulation

Arrow left icon
Product type Paperback
Published in Feb 2017
Publisher Packt
ISBN-13 9781786461155
Length 306 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
 Donovan Donovan
Author Profile Icon Donovan
Donovan
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Mastering Oculus Rift Development
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
1. Exploring a New Reality with the Oculus Rift FREE CHAPTER 2. Stepping into Virtual Reality 3. Improving Performance and Avoiding Discomfort 4. Interacting with Virtual Worlds 5. Establishing Presence 6. Adding Depth and Intuition to a User Interface 7. Hearing and Believing with 3D Audio 8. Adding Tone and Realism with Graphics 9. Bringing Players Together in VR 10. Publishing on the Oculus Store

Object pooling


There's one thing better than optimal deallocation: avoiding deallocation completely. This is where the concept of object pooling comes in. The idea behind object pooling is that we have a finite collection of reference types in memory, and instead of deallocating an object when we're done with it, we add it to the collection to be reused later.

With this method, new allocations only need to be made when there aren't any objects in the collection not being used. Even when new memory needs to be allocated, it goes into the pool to be reused when we're done with it, effectively increasing the capacity of the pool permanently and reducing the odds that we'll need to allocate again in the future.

The following diagram displays how this system works at a high level:

Let's implement a very basic object pool that we can use in all of our future projects to see this principle in action.

Creating an object pool for strings

Since typically only reference types are allocated on the heap...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images