diff --git a/source/Lib/CommonLib/CodingStructure.cpp b/source/Lib/CommonLib/CodingStructure.cpp
index 1d2003baf4d53ae54aada5388910603150368276..0309678df1457448b667c0372ce419af1b1a0d4b 100644
--- a/source/Lib/CommonLib/CodingStructure.cpp
+++ b/source/Lib/CommonLib/CodingStructure.cpp
@@ -1540,13 +1540,13 @@ void CodingStructure::destroyCoeffs()
 {
   for( uint32_t i = 0; i < MAX_NUM_COMPONENT; i++ )
   {
-    m_coeffs[i].clear();
-    m_pcmbuf[i].clear();
+    free(m_coeffs[i]);
+    free(m_pcmbuf[i]);
   }
 
   for (auto &ptr: m_runType)
   {
-    ptr.clear();
+    free(ptr);
   }
 }
 
diff --git a/source/Lib/CommonLib/CommonDef.h b/source/Lib/CommonLib/CommonDef.h
index c1b43982d793246f377b8d50008cf98ca3959a17..4d499d37da45d295ff9512adad121c3543ee732d 100644
--- a/source/Lib/CommonLib/CommonDef.h
+++ b/source/Lib/CommonLib/CommonDef.h
@@ -932,6 +932,12 @@ static inline int ceilLog2(uint32_t x)
   return (x==0) ? -1 : floorLog2(x - 1) + 1;
 }
 
+template<class T> inline void free(std::vector<T>& v)
+{
+  // deallocate the memory used by vector data by swapping the vector with an empty one
+  std::vector<T>().swap(v);
+}
+
 //CASE-BREAK for breakpoints
 #if defined ( _MSC_VER ) && defined ( _DEBUG )
 #define _CASE(_x) if(_x)