Added memory check to writing method in CXI. Makes sure that we do not exceed limits of slice.