def sdram_alloc_as_filelike(self, size, tag=0, x=Required, y=Required,
                                app_id=Required, clear=False):
        """Like :py:meth:`.sdram_alloc` but returns a :py:class:`file-like
        object <.MemoryIO>` which allows safe reading and writing to the block
        that is allocated.

        Returns
        -------
        :py:class:`.MemoryIO`
            File-like object which allows accessing the newly allocated region
            of memory. For example::

                >>> # Read, write and seek through the allocated memory just
                >>> # like a file
                >>> mem = mc.sdram_alloc_as_filelike(12)  # doctest: +SKIP
                >>> mem.write(b"Hello, world")            # doctest: +SKIP
                12
                >>> mem.seek(0)                           # doctest: +SKIP
                >>> mem.read(5)                           # doctest: +SKIP
                b"Hello"
                >>> mem.read(7)                           # doctest: +SKIP
                b", world"

                >>> # Reads and writes are truncated to the allocated region,
                >>> # preventing accidental clobbering/access of memory.
                >>> mem.seek(0)                           # doctest: +SKIP
                >>> mem.write(b"How are you today?")      # doctest: +SKIP
                12
                >>> mem.seek(0)                           # doctest: +SKIP
                >>> mem.read(100)                         # doctest: +SKIP
                b"How are you "

            See the :py:class:`.MemoryIO` class for details of other features
            of these file-like views of SpiNNaker's memory.

        Raises
        ------
        rig.machine_control.machine_controller.SpiNNakerMemoryError
            If the memory cannot be allocated, or the tag is already taken or
            invalid.
        """
        # Perform the malloc
        start_address = self.sdram_alloc(size, tag, x, y, app_id, clear)
        return MemoryIO(self, x, y, start_address, start_address + size)