added shared memory implementation with out length given during declaration