Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
R High Performance Programming

You're reading from  R High Performance Programming

Product type Book
Published in Jan 2015
Publisher
ISBN-13 9781783989263
Pages 176 pages
Edition 1st Edition
Languages

Table of Contents (17) Chapters

R High Performance Programming
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
1. Understanding R's Performance – Why Are R Programs Sometimes Slow? 2. Profiling – Measuring Code's Performance 3. Simple Tweaks to Make R Run Faster 4. Using Compiled Code for Greater Speed 5. Using GPUs to Run R Even Faster 6. Simple Tweaks to Use Less RAM 7. Processing Large Datasets with Limited RAM 8. Multiplying Performance with Parallel Computing 9. Offloading Data Processing to Database Systems 10. R and Big Data Index

Reusing objects without taking up more memory


The first tweak takes advantage of how R manages the memory of objects using a copy-on-modification model. In this model, when a copy of an object x is made, for example with y <- x, it is not actually copied in the memory. Rather, the new variable y simply points to the same block of memory that contains x. The first time when y is modified, R copies the data into a new block of memory so that x and y have their own copies of the data. That is why this model of memory management is called copy-on-modification. What this means is that new objects can sometimes be created from existing objects without taking up additional memory. To identify potential memory bottlenecks and manage the memory utilization of R programs, it is helpful to understand when R copies data and when it does not.

Take for example the following code, which generates a numeric vector x with 1 million elements and creates a list y that contains two copies of x. We can examine...

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}