Index: code/branches/presentation2/src/orxonox/sound/BaseSound.cc
===================================================================
--- code/branches/presentation2/src/orxonox/sound/BaseSound.cc	(revision 6252)
+++ code/branches/presentation2/src/orxonox/sound/BaseSound.cc	(revision 6254)
@@ -44,4 +44,5 @@
     BaseSound::BaseSound()
         : audioSource_(0)
+        , bPooling_(false)
         , volume_(1.0)
         , bLoop_(false)
@@ -166,4 +167,5 @@
             // Unload old sound first
             alSourcei(this->audioSource_, AL_BUFFER, 0);
+            SoundManager::getInstance().releaseSoundBuffer(this->soundBuffer_, this->bPooling_);
             this->soundBuffer_.reset();
         }
Index: code/branches/presentation2/src/orxonox/sound/BaseSound.h
===================================================================
--- code/branches/presentation2/src/orxonox/sound/BaseSound.h	(revision 6252)
+++ code/branches/presentation2/src/orxonox/sound/BaseSound.h	(revision 6254)
@@ -86,5 +86,6 @@
         ALuint loadOggFile();
 
-        ALuint audioSource_;
+        ALuint          audioSource_;
+        bool            bPooling_;
         shared_ptr<SoundBuffer> soundBuffer_;
 
Index: code/branches/presentation2/src/orxonox/sound/SoundBuffer.cc
===================================================================
--- code/branches/presentation2/src/orxonox/sound/SoundBuffer.cc	(revision 6252)
+++ code/branches/presentation2/src/orxonox/sound/SoundBuffer.cc	(revision 6254)
@@ -63,9 +63,16 @@
     SoundBuffer::~SoundBuffer()
     {
-        // Unregister buffer from SoundManager
-        SoundManager::getInstance().removeBuffer(this->fileInfo_);
-
         // Destroy buffer
         alDeleteBuffers(1, &this->audioBuffer_);
+    }
+
+    unsigned int SoundBuffer::getSize() const
+    {
+        ALint size;
+        alGetBufferi(this->audioBuffer_, AL_SIZE, &size);
+        if (!alGetError())
+            return size;
+        else
+            return 0;
     }
 
Index: code/branches/presentation2/src/orxonox/sound/SoundBuffer.h
===================================================================
--- code/branches/presentation2/src/orxonox/sound/SoundBuffer.h	(revision 6252)
+++ code/branches/presentation2/src/orxonox/sound/SoundBuffer.h	(revision 6254)
@@ -41,4 +41,6 @@
     class _OrxonoxExport SoundBuffer
     {
+        friend class SoundManager;
+
     public:
         SoundBuffer(shared_ptr<ResourceInfo> fileInfo);
@@ -48,4 +50,14 @@
             { return this->audioBuffer_; }
 
+        unsigned int getSize() const;
+
+        shared_ptr<ResourceInfo> getFileInfo() const
+            { return this->fileInfo_; }
+
+        void setPooling(bool val)
+            { this->bPooling_ = true; }
+        bool getPooling() const
+            { return this->bPooling_; }
+
     private:
         void loadStandard(DataStreamPtr dataStream);
@@ -54,4 +66,6 @@
         shared_ptr<ResourceInfo> fileInfo_;
         ALuint audioBuffer_;
+        std::list<shared_ptr<SoundBuffer> >::iterator poolIterator_;
+        bool bPooling_;
     };
 }
Index: code/branches/presentation2/src/orxonox/sound/SoundManager.cc
===================================================================
--- code/branches/presentation2/src/orxonox/sound/SoundManager.cc	(revision 6252)
+++ code/branches/presentation2/src/orxonox/sound/SoundManager.cc	(revision 6254)
@@ -52,4 +52,5 @@
 
     SoundManager::SoundManager()
+        : effectsPoolSize_(0)
     {
         RegisterRootObject(SoundManager);
@@ -529,31 +530,67 @@
     shared_ptr<SoundBuffer> SoundManager::getSoundBuffer(shared_ptr<ResourceInfo> fileInfo)
     {
-        std::map<std::string, weak_ptr<SoundBuffer> >::const_iterator it
-            = this->soundBuffers_.find(fileInfo->group + '/' + fileInfo->filename);
+        shared_ptr<SoundBuffer> buffer;
+        // Check active or pooled buffers
+        SoundBufferMap::const_iterator it = this->soundBuffers_.find(fileInfo->group + '/' + fileInfo->filename);
         if (it != this->soundBuffers_.end())
-            return it->second.lock();
+        {
+            buffer = it->second;
+
+            // Remove from effects pool if not active used before
+            if (buffer->poolIterator_ != this->effectsPool_.end())
+            {
+                this->effectsPoolSize_ -= buffer->getSize();
+                this->effectsPool_.erase(buffer->poolIterator_);
+                buffer->poolIterator_ = this->effectsPool_.end();
+            }
+        }
         else
         {
-            shared_ptr<SoundBuffer> buffer;
             try
             {
                 buffer.reset(new SoundBuffer(fileInfo));
+                buffer->poolIterator_ = this->effectsPool_.end();
             }
             catch (...)
             {
                 COUT(1) << Exception::handleMessage() << std::endl;
-                return shared_ptr<SoundBuffer>();
+                return buffer;
             }
             this->soundBuffers_[fileInfo->group + '/' + fileInfo->filename] = buffer;
-            return buffer;
-        }
-    }
-
-    void SoundManager::removeBuffer(shared_ptr<ResourceInfo> fileInfo)
-    {
-        std::map<std::string, weak_ptr<SoundBuffer> >::iterator it
-            = this->soundBuffers_.find(fileInfo->group + '/' + fileInfo->filename);
+        }
+        return buffer;
+    }
+
+    void SoundManager::releaseSoundBuffer(const shared_ptr<SoundBuffer>& buffer, bool bPoolBuffer)
+    {
+        // Check if others are still using the buffer
+        if (buffer.use_count() != 2)
+            return;
+        SoundBufferMap::iterator it = this->soundBuffers_.find(buffer->fileInfo_->group + '/' + buffer->fileInfo_->filename);
         if (it != this->soundBuffers_.end())
-            this->soundBuffers_.erase(it);
+        {
+            if (bPoolBuffer)
+            {
+                // Pool already too large?
+                while (this->effectsPoolSize_ + it->second->getSize() > this->maxEffectsPoolSize_s && !this->effectsPool_.empty())
+                {
+                    shared_ptr<SoundBuffer> bufferDel = this->effectsPool_.back();
+                    this->effectsPoolSize_ -= bufferDel->getSize();
+                    bufferDel->poolIterator_ = this->effectsPool_.end();
+                    this->effectsPool_.pop_back();
+                    // Remove from buffer map too
+                    SoundBufferMap::iterator itDel = this->soundBuffers_.find(bufferDel->fileInfo_->group + '/' + bufferDel->fileInfo_->filename);
+                    if (itDel != this->soundBuffers_.end())
+                        this->soundBuffers_.erase(itDel);
+                }
+                // Put buffer into the pool
+                this->effectsPoolSize_ += it->second->getSize();
+                this->effectsPool_.push_front(it->second);
+                it->second->poolIterator_ = this->effectsPool_.begin();
+                COUT(0) << "pool size: " << this->effectsPoolSize_ << std::endl;
+            }
+            else
+                this->soundBuffers_.erase(it);
+        }
     }
 }
Index: code/branches/presentation2/src/orxonox/sound/SoundManager.h
===================================================================
--- code/branches/presentation2/src/orxonox/sound/SoundManager.h	(revision 6252)
+++ code/branches/presentation2/src/orxonox/sound/SoundManager.h	(revision 6254)
@@ -36,5 +36,5 @@
 #include <map>
 #include <string>
-#include <boost/weak_ptr.hpp>
+#include <boost/shared_ptr.hpp>
 
 #include "util/Singleton.h"
@@ -101,5 +101,5 @@
 
         shared_ptr<SoundBuffer> getSoundBuffer(shared_ptr<ResourceInfo> fileInfo);
-        void removeBuffer(shared_ptr<ResourceInfo> fileInfo);
+        void releaseSoundBuffer(const shared_ptr<SoundBuffer>& buffer, bool bPoolBuffer);
 
         static std::string getALErrorString(ALenum error);
@@ -139,5 +139,10 @@
         std::map<SoundType::Value, bool> mute_;
 
-        std::map<std::string, weak_ptr<SoundBuffer> > soundBuffers_;
+        static const unsigned int maxEffectsPoolSize_s = 40 * 1024 * 1024;
+        unsigned int effectsPoolSize_;
+        typedef std::list<shared_ptr<SoundBuffer> > EffectsPoolList;
+        EffectsPoolList effectsPool_;
+        typedef std::map<std::string, shared_ptr<SoundBuffer> > SoundBufferMap;
+        SoundBufferMap soundBuffers_;
         
         static SoundManager* singletonPtr_s;
Index: code/branches/presentation2/src/orxonox/sound/WorldSound.cc
===================================================================
--- code/branches/presentation2/src/orxonox/sound/WorldSound.cc	(revision 6252)
+++ code/branches/presentation2/src/orxonox/sound/WorldSound.cc	(revision 6254)
@@ -45,4 +45,6 @@
     {
         RegisterObject(WorldSound);
+        // WorldSound buffers should be pooled when they're not used anymore
+        this->bPooling_ = true;
     }
 
