# Adding metadata takes up ram

**URL:** <https://forums.plex.tv/t/adding-metadata-takes-up-ram/169384>\
**Category:** Dev/API Corner\
**Tags:** scanner-agent-dev\
**Created:** [December 2, 2016, 4:32am UTC](https://forums.plex.tv/t/adding-metadata-takes-up-ram/169384 "2016-12-02T04:32:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brenden\_Carvalho](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/brenden_carvalho/32/83392_2.png) [@Brenden\_Carvalho](https://forums.plex.tv/u/Brenden_Carvalho)\
**Post date:** [December 2, 2016, 4:32am UTC](https://forums.plex.tv/t/adding-metadata-takes-up-ram/169384/1 "2016-12-02T04:32:57Z")

</div>

Hi,  
I’ve been working on a agent which downloads posters/background in a zip file (~120MB) to memory and then processes it and then adds them.  
Here’s the relevant code [http://pastebin.com/DQ4yL8Cu](http://pastebin.com/DQ4yL8Cu) in the update function.

The issue is that i have a ton of pics (maybe ~500 pics per movie), and when i iterate through the entire zip file and add them it works, but the memory used by my plug-in begins to increase every time i run it.

I have narrowed down the issue to the the statement that adds the metadata,  
`metadata.posters[pics]=Proxy.Media(zip_archive[pics], sort_order = pcount) metadata.art[pics]=Proxy.Media(zip_archive[pics], sort_order = acount)`

If I leave everything as is and just comment out those lines the memory issue is gone.  
Is there anyway I can force the metadata to be written to disk and then deleted from memory?

Can anyone here help me?  
Thanks,

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [January 8, 2020, 8:00pm UTC](https://forums.plex.tv/t/adding-metadata-takes-up-ram/169384/2 "2020-01-08T20:00:37Z")

</div>

Closed on January 8, 2020, 8:00pm UTC


