diff -ubBwr --exclude=uploads --exclude=images --exclude=images_pcf --exclude=config.php --exclude=languages/polish --exclude=settings.php src_original/inc/functions.php forum/inc/functions.php
--- src_original/inc/functions.php	2008-11-27 19:00:00.000000000 +0100
+++ forum/inc/functions.php	2009-01-28 09:21:17.000000000 +0100
@@ -4461,6 +4518,14 @@
 {
 	global $db;
 	static $thread_cache;
+	// KK: limit_size_of_static_thread_cache_mod
+	static $thread_cache_count ;
+	if (!isset($thread_cache_count))
+	{
+		$thread_cache_count = 0 ;
+	}
+	$thread_cache_max_count = 128 ;
+	// KK: limit_size_of_static_thread_cache_mod
 
 	if(isset($thread_cache[$tid]))
 	{
@@ -4473,12 +4538,26 @@
 
 		if($thread)
 		{
+			// KK: limit_size_of_static_thread_cache_mod
+			// $thread_cache[$tid] = $thread;
+			if ($thread_cache_count < $thread_cache_max_count)
+			{
 			$thread_cache[$tid] = $thread;
+				$thread_cache_count++ ;
+			}
+			// KK: limit_size_of_static_thread_cache_mod
 			return $thread;
 		}
 		else
 		{
+			// KK: limit_size_of_static_thread_cache_mod
+			// $thread_cache[$tid] = false;
+			if ($thread_cache_count < $thread_cache_max_count)
+			{
 			$thread_cache[$tid] = false;
+				$thread_cache_count++ ;
+			}
+			// KK: limit_size_of_static_thread_cache_mod
 			return false;
 		}
 	}


