1

Process 1:

shm=multiprocessing.shared_memory.SharedMemory(name="shm", create=True, size=10000) print(shm.size) 

Prints 10000

Process 2:

shm=multiprocessing.shared_memory.SharedMemory(name="shm") print(shm.size) 

Prints 12288

The problem is that I'm trying to use the buffer to back a numpy array. Then numpy complains it cannot reshape() the array because it is not the same size.

1 Answer 1

2
+50

shared memory is rounded to the next page size, which is in your case 3 * 4096. You have to slice the buffer to the correct size

shm = multiprocessing.shared_memory.SharedMemory(name="shm") buffer = shm.buf[:10000] 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.