# Garbage Collector and IPFS Pinning

**URL:** <https://discuss.ipfs.tech/t/garbage-collector-and-ipfs-pinning/4055>\
**Category:** Ecosystem and Usage\
**Created:** [October 15, 2018, 6:53pm UTC](https://discuss.ipfs.tech/t/garbage-collector-and-ipfs-pinning/4055 "2018-10-15T18:53:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![NatalieChin80](https://avatars.discourse-cdn.com/v4/letter/n/b19c9b/32.png) [@NatalieChin80](https://discuss.ipfs.tech/u/NatalieChin80)\
**Post date:** [October 15, 2018, 6:53pm UTC](https://discuss.ipfs.tech/t/garbage-collector-and-ipfs-pinning/4055/1 "2018-10-15T18:53:20Z")

</div>

This is my first time exploring IPFS. My biggest confusions at the moment are around how the garbage collector works and how IPFS pinning works.

For instance, if I build a decentralized Spotify, and post music on IPFS - what would the conditions be for the garbage collector to delete the files? Is it possible, that if a user tries to access it, the file is gone?

On top of that, regarding `ipfs pinning`, the docs mentioned that “pinning” an item is essentially marking it for the garbage collector not to delete it, so it will not deleted. Am I correct in this assumption?

More specifically, how exactly does IPFS pinning work as a whole? Whatever the file is, if pinned - does that mean it’s pinned _on most nodes_ or _just the node that pushes it?_ If it’s the former, then wouldn’t there be scaling issues with too many files marked as un-deletable? If it is the latter, wouldn’t this mean that the initial node has to be up and running to be able to access the file? Would this then be a centralized solution?

In some threads here, I also read that by adding a file through `ipfs`, you are automatically pinning it to your node. Can I get some clarification on this? If `ipfs add <file>` keeps the file always accessible, then what’s the difference between this and pinning it?

---

<div class="post-metadata">

**Author:** ![lidel](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/lidel/32/9853_2.png) [@lidel](https://discuss.ipfs.tech/u/lidel)\
**Post date:** [October 21, 2018, 11:08am UTC](https://discuss.ipfs.tech/t/garbage-collector-and-ipfs-pinning/4055/2 "2018-10-21T11:08:57Z")

</div>

> [@NatalieChin80](#):
>
> the docs mentioned that “pinning” an item is essentially marking it for the garbage collector not to delete it, so it will not deleted. Am I correct in this assumption?

Correct 🙂

> [@NatalieChin80](#):
>
> Whatever the file is, if pinned - does that mean it’s pinned on most nodes or just the node that pushes it?

Just your node. Every IPFS node has its own independent set of pins. You decide what is pinned on your node, nobody can force you to do so. If you have multiple nodes under your control you can coordinate pinning using IPFS Cluster ([https://cluster.ipfs.io](https://cluster.ipfs.io)).

> [@NatalieChin80](#):
>
> wouldn’t this mean that the initial node has to be up and running to be able to access the file? Would this then be a centralized solution?

This is similar to how BitTorrent works: there needs to be at least one seed for data to be available to the network. Just like with pins, every node decides what content is fetched and seeded (co-hosted). If nobody else cares about your data, the data will be “forgotten”.

> [@NatalieChin80](#):
>
> In some threads here, I also read that by adding a file through ipfs, you are automatically pinning it to your node. Can I get some clarification on this? If ipfs add \<file\> keeps the file always accessible, then what’s the difference between this and pinning it?

When you add local data via `ipfs add` it will be pinned by default, so the data you care about won’t be garbage collected. You can also manually `ipfs pin` data that is already on IPFS to help with co-hosting it.

To be more specific, the API is `ipfs.files.add(data, [options])` and one of default options is `pin=true`.  
You can override that behaviour by passing `pin=false` in `options`.  
That way data will be added to IPFS, but won’t be pinned.
