Index: wp-includes/default-constants.php
===================================================================
--- wp-includes/default-constants.php	(revision 18204)
+++ wp-includes/default-constants.php	(working copy)
@@ -39,8 +39,11 @@
 		$blog_id = 1;
 
 	// set memory limits.
-	if ( function_exists('memory_get_usage') && ( (int) @ini_get('memory_limit') < abs(intval(WP_MEMORY_LIMIT)) ) )
-		@ini_set('memory_limit', WP_MEMORY_LIMIT);
+	if ( function_exists('memory_get_usage') ) {
+		$current_limit = @ini_get('memory_limit');
+		if ( -1 != $current_limit && ( -1 == WP_MEMORY_LIMIT || ( inval( $current_limit ) < abs( intval( WP_MEMORY_LIMIT ) ) ) ) )
+			@ini_set('memory_limit', WP_MEMORY_LIMIT);
+	}
 
 	if ( !defined('WP_CONTENT_DIR') )
 		define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down
