The Tragedy of the Computer Commons
Economics
Development
originally posted at https://debpu06.substack.com/p/the-tragedy-of-the-computer-commons
The average computer user gives little thought to the inner workings of their device. When purchasing your computer, most people assume that a bigger hard drive, more RAM, faster CPU, all equal a better machine. But day to day, unless your device starts to slow down or you get a low disk space warning, you don't give the hardware much thought.
As a developer, one of the first things I learned was how code affects memory (RAM). Memory is a shared resource across all the applications on your computer, as well as the operating system. Developers used to have to be very intentional about how they used memory. This, however, is no longer the norm, and you, the end users, suffer for it.
Thanks for reading David Boland Blog! Subscribe for free to receive new posts and support my work.
Understanding Memory
If you have heard of memory (RAM), but never really understood what it does, you can think of it as the same as your hard drive, only much faster. Your hard drive stores the data applications need when they run. In the basic example of a word processor, this includes not only the document file itself, but the program used to read and edit it.
Once you open that document, the application still needs to store that data, but it needs to access it much faster than what a hard drive can deliver. So, when you open an application, data loads from the hard drive into memory. That's why, when you first double click to open that document for example, it takes a second or two to open. After that, you can start editing much more quickly. Once the application is loaded, most of the data required to view and edit the file is in memory.
While memory is faster than your hard drive, it has the downside of not being persistent, and having limited space. While most new computers come with hard drives that are over a terabyte, memory is in the 16-32 gigabyte range, and is cleared when your computer shuts down.
Programming with Memory in Mind
In the early days of programming, developers had to manage memory themselves. You had to write your program to request the space in memory for the data it was working with. Developers even had to consider whether they would use integers or higher precision floating point numbers because each could take up a different amount of memory. When you were done with that memory, you had to manually release it. In these early days memory was so limited, you had to manage it carefully for your application to run at all.
More modern programming languages are smart enough to manage the memory automatically. If it perceives your application is no longer using some memory, it will automatically release it from the application.
When I was first learning development in school, we learned Java and C as our first languages. Java has built-in memory management. C does not. These days, the most popular programming languages for new developers, such as Java, JavaScript, Python, etc., all come with built in memory management, commonly called "garbage collection".
The lack of needing to worry about memory management, combined with the abundance of RAM in modern machines, has led to a "tragedy of the commons" effect for your system's resources.
Tragedy of the Commons
The tragedy of the commons is an economic concept that deals with the sharing of resources. The idea behind it is that when individuals have access to a shared resource, they tend to act in their own self interest, and overuse it. This leads to resource depletion.
A classic example is a group of farmers whose properties surround a piece of public land. If they kept their cattle on their own land, they would avoid overgrazing. However, if the public land were to become accessible to everyone, the farmers would have no incentive to stop their cattle from overgrazing that shared land. This overconsumption leads to the shared resource being depleted.
Conceptually, this is what happens on your computer. A clear example of this would be your browser. Say you are browsing the web with Google Chrome, which in itself uses up some memory. Each site you visit takes up a bit of memory as well. If you were to leave one tab open and open another, the sites from each tab takes up some amount of memory. If you are someone like myself, who can often have multiple Chrome windows open, each with 10+ tabs, memory usage adds up. If you also happen to have Spotify open, as well as a note-taking app and messaging tool, you can see how that memory usage can shoot up quickly.
The "tragedy" of it is that developers don't tend to consider this when developing applications. Sure if they are building an application, they will try to fix any memory leaks. And they don't intend to use up all the resources. But if they can add a smoother animation, more data on the page, or increase the performance by using just a bit more memory, they will.
And this is one of the reasons computers seem to get "slower" over time. It's less that your computer is getting slower, and more that you tend to want more applications running simultaneously, and those apps tend to demand more resources.
Final Thoughts
When economists talk about instances of the tragedy of the commons, the proposed solutions tend to be (usually government) regulation.
Unfortunately, this type of regulation doesn't exist for your computer. Sure an iOS app might not make it to the Apple App Store if Apple's review process determines you are using up all the memory. But most applications we install to our devices aren't as strictly regulated.
Each of us will just have to remember to work with what we have. Close those extra tabs, be mindful of what applications we have running, and remember to restart our machines more than once a month.