diff --git a/PhpAmqpLib/Connection/AbstractConnection.php b/PhpAmqpLib/Connection/AbstractConnection.php
index <HASH>..<HASH> 100644
--- a/PhpAmqpLib/Connection/AbstractConnection.php
+++ b/PhpAmqpLib/Connection/AbstractConnection.php
@@ -419,14 +419,16 @@ class AbstractConnection extends AbstractChannel
 
         $pkt->write_octet(0xCE);
 
-        while ($body !== '') {
-            $bodyStart = ($this->frame_max - 8);
-            $payload = mb_substr($body, 0, $bodyStart, 'ASCII');
-            $body = (string)mb_substr($body, $bodyStart, mb_strlen($body, 'ASCII') - $bodyStart, 'ASCII');
+        // memory efficiency: walk the string instead of biting it. good for very large packets (100+mb)
+        $position = 0;
+        $bodyLength = mb_strlen($body,'8bit');
+        while ($position <= $bodyLength) {
+            $payload = mb_substr($body, $position, $this->frame_max - 8, '8bit');
+            $position += $this->frame_max - 8;
 
             $pkt->write_octet(3);
             $pkt->write_short($channel);
-            $pkt->write_long(mb_strlen($payload, 'ASCII'));
+            $pkt->write_long(mb_strlen($payload, '8bit'));
 
             $pkt->write($payload);
changed the way prepare content splits the body. now should be a bit more memory efficient