# Shared memory from python

**URL:** <http://forum.vvvv.org/t/shared-memory-from-python/17092>\
**Category:** question\
**Created:** [January 8, 2019, 7:13pm UTC](http://forum.vvvv.org/t/shared-memory-from-python/17092 "2019-01-08T19:13:33Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![k3XX](http://forum.vvvv.org/letter_avatar_proxy/v2/letter/k/999999/32.png) [@k3XX](http://forum.vvvv.org/u/k3XX)\
**Post date:** [January 8, 2019, 7:13pm UTC](http://forum.vvvv.org/t/shared-memory-from-python/17092/1 "2019-01-08T19:13:33Z")

</div>

Is there any info on sending data from other apps to vvvv trough shared memory? Is the shared memory node using memory mapped files?

I checked the help patch of Reader/Writer Raw SharedMemory node but it’s not clear for me if vvvv uses memory mapped files then why it uses “names” instead of filenames to identify memory locations?

---

<div class="post-metadata">

**Author:** ![joreg](http://forum.vvvv.org/user_avatar/forum.vvvv.org/joreg/32/19824_2.png) [@joreg](http://forum.vvvv.org/u/joreg)\
**Post date:** [January 8, 2019, 7:19pm UTC](http://forum.vvvv.org/t/shared-memory-from-python/17092/2 "2019-01-08T19:19:33Z")

</div>

> [@k3XX](#):
>
> it’s not clear for me if vvvv uses memory mapped files then why it uses “names” instead of filenames to identify memory locations?

to my understanding you can use any string to identify a memory mapped file. doesn’t have to be a “filename” in the traditional sense.

---

<div class="post-metadata">

**Author:** ![k3XX](http://forum.vvvv.org/letter_avatar_proxy/v2/letter/k/999999/32.png) [@k3XX](http://forum.vvvv.org/u/k3XX)\
**Post date:** [January 8, 2019, 7:25pm UTC](http://forum.vvvv.org/t/shared-memory-from-python/17092/3 "2019-01-08T19:25:34Z")

</div>

I’m confused because to my understanding in python memory mapped files either correspond to an actual file on the disk or being anonymous:

[https://docs.python.org/2/library/mmap.html](https://docs.python.org/2/library/mmap.html)

---

<div class="post-metadata">

**Author:** ![joreg](http://forum.vvvv.org/user_avatar/forum.vvvv.org/joreg/32/19824_2.png) [@joreg](http://forum.vvvv.org/u/joreg)\
**Post date:** [January 8, 2019, 7:38pm UTC](http://forum.vvvv.org/t/shared-memory-from-python/17092/4 "2019-01-08T19:38:19Z")

</div>

ok, i only knew of anonymous so far, which the Reader/Writer (Raw SharedMemory) are using. if you need a persistent file you’ll have to write your own little plugin.

seems to be just a few lines of code, see:

> **[MemoryMappedFile Class (System.IO.MemoryMappedFiles)](https://learn.microsoft.com/en-us/dotnet/api/system.io.memorymappedfiles.memorymappedfile?view=netframework-4.7.2)**
>
> Represents a memory-mapped file.

and here is how to write a dynamic plugin in vvvv using c#:

> **[Dynamic Plugins Reference](https://vvvv.org/documentation/dynamic-plugins-reference)**
>
> Cloning a Template
> PluginInfo
> Defining Pins
> 
> 
> 
> Attribute examples
> IDiffSpread example
> Spread of Spread example
> PinGroup example
> PinInfo attribute
> Variable declarations
> Spread of Spread
> Add/Remove pin

---

<div class="post-metadata">

**Author:** ![k3XX](http://forum.vvvv.org/letter_avatar_proxy/v2/letter/k/999999/32.png) [@k3XX](http://forum.vvvv.org/u/k3XX)\
**Post date:** [January 9, 2019, 7:36am UTC](http://forum.vvvv.org/t/shared-memory-from-python/17092/5 "2019-01-09T07:36:23Z")

</div>

Ah, I see. Thank you for the help!

---

<div class="post-metadata">

**Author:** ![sinao](http://forum.vvvv.org/user_avatar/forum.vvvv.org/sinao/32/6130_2.png) [@sinao](http://forum.vvvv.org/u/sinao)\
**Post date:** [March 21, 2019, 4:07pm UTC](http://forum.vvvv.org/t/shared-memory-from-python/17092/6 "2019-03-21T16:07:00Z")

</div>

There is a new feature in python 3.8 allowing you to share memory from python to vvvv right out of the box:

> **[multiprocessing.shared\_memory — Shared memory for direct access across processes](https://docs.python.org/3.8/library/multiprocessing.shared_memory.html)**
>
> Source code: Lib/multiprocessing/shared\_memory.py This module provides a class, SharedMemory, for the allocation and management of shared memory to be accessed by one or more processes on a multico...

 ![image](http://forum.vvvv.org/uploads/default/original/2X/a/a72bc47963f733d2ac99240739d14313326fa8d3.png)

---

<div class="post-metadata">

**Author:** ![k3XX](http://forum.vvvv.org/letter_avatar_proxy/v2/letter/k/999999/32.png) [@k3XX](http://forum.vvvv.org/u/k3XX)\
**Post date:** [March 21, 2019, 6:13pm UTC](http://forum.vvvv.org/t/shared-memory-from-python/17092/7 "2019-03-21T18:13:45Z")

</div>

@sinao That’s nice! Thanks for sharing!

---

<div class="post-metadata">

**Author:** ![soundreactor](http://forum.vvvv.org/user_avatar/forum.vvvv.org/soundreactor/32/220_2.png) [@soundreactor](http://forum.vvvv.org/u/soundreactor)\
**Post date:** [April 4, 2019, 10:31pm UTC](http://forum.vvvv.org/t/shared-memory-from-python/17092/8 "2019-04-04T22:31:30Z")

</div>

if you need older pythons use this ( works in python 3.7. )

 ![vvvv_2019-04-05_00-28-05](http://forum.vvvv.org/uploads/default/original/2X/a/a94fecae8c154e0fbff8c812c141b2ada6388db5.png)

---

<div class="post-metadata">

**Author:** ![system](http://forum.vvvv.org/user_avatar/forum.vvvv.org/system/32/1_2.png) [@system](http://forum.vvvv.org/u/system)\
**Post date:** [April 3, 2020, 10:31pm UTC](http://forum.vvvv.org/t/shared-memory-from-python/17092/9 "2020-04-03T22:31:33Z")

</div>

Closed on April 3, 2020, 10:31pm UTC

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
