class_docstr: SharedMem allows you to allocate and access shared memory.
  Provides memory view of the allocated memory via buf property.
  You can transfer access to the same shared memory chunk by sending related shared memory
  handle (file descriptor on Unix) available as handle property. Use SharedMem.allocate
  to allocate new chunk of shared memory and SharedMem.open if you received handle to already
  existing memory chunk.
  
  There is out of the box support for shared memory starting from Python3.8, though
  the only way there to transfer the memory to other processes is via filename,
  which might 'leak' if process was closed abruptly.
  
  Parameters
  ----------
  `handle` : int
      Handle identifying related shared memory object. Pass None to allocate new memory chunk.
  `size` : int
      When handle=None it is the size of shared memory to allocate in bytes, otherwise it must be
      the size of shared memory objects that provided handle represents.
class_docstr_tok: ["SharedMem","allows","you","to","allocate","and","access","shared","memory",".","Provides","memory","view","of","the","allocated","memory","via","buf","property",".","You","can","transfer","access","to","the","same","shared","memory","chunk","by","sending","related","shared","memory","handle","(","file","descriptor","on","Unix",")","available","as","handle","property",".","Use","SharedMem.allocate","to","allocate","new","chunk","of","shared","memory","and","SharedMem.open","if","you","received","handle","to","already","existing","memory","chunk",".","There","is","out","of","the","box","support","for","shared","memory","starting","from","Python3.8",",","though","the","only","way","there","to","transfer","the","memory","to","other","processes","is","via","filename",",","which","might","'leak","'","if","process","was","closed","abruptly",".","Parameters","--","--","--","--","--","`","handle","`",":","int","Handle","identifying","related","shared","memory","object",".","Pass","None","to","allocate","new","memory","chunk",".","`","size","`",":","int","When","handle=None","it","is","the","size","of","shared","memory","to","allocate","in","bytes",",","otherwise","it","must","be","the","size","of","shared","memory","objects","that","provided","handle","represents","."]
docstr: Resize already allocated shared memory chunk. If you want to resize the underlying
  shared memory chunk pass trunc=True, if the memory chunk has already been resized
  via another SharedMem instance (possibly in another process), pass new size and
  trunc=False to simply adjust mmaping of the memory into the current process address space.
docstr_tok: ["Resize","already","allocated","shared","memory","chunk",".","If","you","want","to","resize","the","underlying","shared","memory","chunk","pass","trunc=True",",","if","the","memory","chunk","has","already","been","resized","via","another","SharedMem","instance","(","possibly","in","another","process",")",",","pass","new","size","and","trunc=False","to","simply","adjust","mmaping","of","the","memory","into","the","current","process","address","space","."]
code: def resize(self, size, trunc=False):
      """Resize already allocated shared memory chunk. If you want to resize the underlying
      shared memory chunk pass trunc=True, if the memory chunk has already been resized
      via another SharedMem instance (possibly in another process), pass new size and
      trunc=False to simply adjust mmaping of the memory into the current process address space.
      """
      if "buf" in self.__dict__:
          del self.__dict__["buf"]
      self.shm.resize(size, trunc)
      self.capacity = size
  
file_path: DALI/dali/python/nvidia/dali/_multiproc/shared_mem.py
imports: import os
  from nvidia.dali import backend
label_desc: Use image node_id 6 for calling the SharedMem obj's underlying member method code with example usage: obj.resize(size, trunc) without return types