diff --git a/src/include/tfrfme.h b/src/include/tfrfme.h
index 9230e72ce903cb5498c6f84787033c9e5f6a472c..8e92f7af6a94a0f3de39f2f213809775aad55058 100644
--- a/src/include/tfrfme.h
+++ b/src/include/tfrfme.h
@@ -69,6 +69,13 @@ public:
    */
   std::complex<double> get_element(int index) { return wk[index]; }
 
+  /*! \brief Calculate the necessary amount of memory to create a new instance.
+   *
+   * \param lm: `int` Maximum field expansion order.
+   * \return size: `long` The necessary memory size in bytes.
+   */
+  static long get_memory_requirement(int lm);
+  
   /*! \brief Set an element in the WK vector.
    *
    * \param index: `int` Index of the desired element.
@@ -185,6 +192,13 @@ public:
    */
   double get_matrix_element(int row, int col) { return vkzm[row][col]; }
 
+  /*! \brief Calculate the necessary amount of memory to create a new instance.
+   *
+   * \param _nkv: `int` Number of radial vector coordinates. QUESTION: correct?
+   * \return size: `long` The necessary memory size in bytes.
+   */
+  static long get_memory_requirement(int _nkv);
+
   /*! \brief Get a parameter by its name.
    *
    * \param param_name: `string` Name of the parameter.
@@ -349,6 +363,21 @@ public:
    */
   std::complex<double> get_matrix_element(int row, int col);
 
+  /*! \brief Calculate the necessary amount of memory to create a new instance.
+   *
+   * \param _lmode: `int` Order expansion mode flag.
+   * \param _lm: `int` Maximum field expansion order.
+   * \param _nkv: `int` Number of radial vector coordinates. QUESTION: correct?
+   * \param _nxv: `int` Number of computed X coordinates.
+   * \param _nyv: `int` Number of computed Y coordinates.
+   * \param _nzv: `int` Number of computed Z coordinates.
+   * \return size: `long` The necessary memory size in bytes.
+   */
+  static long get_memory_requirement(
+				     int _lmode, int _lm, int _nkv, int _nxv,
+				     int _nyv, int _nzv
+  );
+
   /*! \brief Get a configuration parameter.
    *
    * \param param_name: `string` Name of the parameter.
diff --git a/src/libnptm/tfrfme.cpp b/src/libnptm/tfrfme.cpp
index b126bbc7e051349d15af542b6465f99935fdf1b4..df4f435e8555bdd9be03de9d77e604c176becc61 100644
--- a/src/libnptm/tfrfme.cpp
+++ b/src/libnptm/tfrfme.cpp
@@ -97,6 +97,12 @@ Swap1* Swap1::from_legacy(string file_name) {
   return instance;
 }
 
+long Swap1::get_memory_requirement(int lm) {
+  long size = (long)sizeof(int);
+  size += (long)(sizeof(complex<double>) * 2 * lm * (lm + 2));
+  return size;
+}
+
 void Swap1::write_binary(string file_name, string mode) {
   if (mode.compare("LEGACY") == 0) {
     write_legacy(file_name);
@@ -302,6 +308,12 @@ Swap2* Swap2::from_legacy(string file_name) {
   return instance;
 }
 
+long Swap2::get_memory_requirement(int _nkv) {
+  long size = (long)(3 * sizeof(int) + 11 * sizeof(double));
+  size += (long)(sizeof(double) * _nkv * (_nkv + 1));
+  return size;
+}
+
 double Swap2::get_param(string param_name) {
   double value;
   if (param_name.compare("nkv") == 0) value = 1.0 * nkv;
@@ -711,6 +723,18 @@ std::complex<double> TFRFME::get_matrix_element(int row, int col) {
   return wsum[row][col];
 }
 
+long TFRFME::get_memory_requirement(
+				    int _lmode, int _lm, int _nkv, int _nxv,
+				    int _nyv, int _nzv
+) {
+  int _nlmmt = 2 * _lm * (_lm + 2);
+  int _nrvc = _nxv * _nyv * _nzv;
+  long size = (long)(8 * sizeof(int) + 8 * sizeof(double));
+  size += (long)((_nxv + _nyv + _nzv) * sizeof(double));
+  size += (long)(_nlmmt * _nrvc * sizeof(complex<double>));
+  return size;
+}
+
 double TFRFME::get_param(string param_name) {
   double value;
   if (param_name.compare("vk") == 0) value = vk;
diff --git a/src/make.inc b/src/make.inc
index c56fd1334e83be3d50ed2363a3ccfc8d2df375b2..dcdd896f0619de451fcf37eaeb62ec664f21c8e6 100644
--- a/src/make.inc
+++ b/src/make.inc
@@ -40,8 +40,8 @@ endif
 
 # CXXFLAGS defines the default compilation options for the C++ compiler
 ifndef CXXFLAGS
-#override CXXFLAGS=-O0 -ggdb -pg -coverage -I$(HDF5_INCLUDE)
-override CXXFLAGS=-O3 -I$(HDF5_INCLUDE)
+override CXXFLAGS=-O3 -ggdb -pg -coverage -I$(HDF5_INCLUDE)
+#override CXXFLAGS=-O3 -I$(HDF5_INCLUDE)
 endif
 
 # HDF5_LIB defines the default path to the HDF5 libraries to use
diff --git a/src/trapping/cfrfme.cpp b/src/trapping/cfrfme.cpp
index b99dd02d118014654fe39d364cc67089edcba212..79c68e35e21cfe5b6fd1c9864101a03b1281dd53 100644
--- a/src/trapping/cfrfme.cpp
+++ b/src/trapping/cfrfme.cpp
@@ -225,6 +225,15 @@ void frfme(string data_file, string output_path) {
 	/*vkv = new double[nkv]();
 	vkzm = new double*[nkv];
 	for (int vi = 0; vi < nkv; vi++) vkzm[vi] = new double[nkv];*/
+	long swap1_size, swap2_size, tfrfme_size;
+	double size_mb;
+	printf("INFO: calculation memory requirements\n");
+	swap1_size = Swap1::get_memory_requirement(lm);
+	size_mb = 1.0 * swap1_size / 1024.0 / 1024.0;
+	printf("Swap 1: %.2lg MB\n", size_mb);
+	swap2_size = Swap2::get_memory_requirement(nkv);
+	size_mb = 1.0 * swap2_size / 1024.0 / 1024.0;
+	printf("Swap 2: %.2lg MB\n", size_mb);
 	tt2 = new Swap2(nkv);
 	// End of array initialization
 	double vkm = vk * exri;
@@ -243,6 +252,11 @@ void frfme(string data_file, string output_path) {
 	int nzs = nzsh * 2;
 	int nzv = nzs + 1;
 	int nzshpo = nzsh + 1;
+	tfrfme_size = TFRFME::get_memory_requirement(lmode, lm, nkv, nxv, nyv, nzv);
+	size_mb = 1.0 * tfrfme_size / 1024.0 / 1024.0;
+	printf("TFRFME: %.2lg MB\n", size_mb);
+	size_mb = 1.0 * (swap1_size + swap2_size + tfrfme_size) / 1024.0 / 1024.0;
+	printf("TOTAL: %.2lg MB\n", size_mb);
 	tfrfme = new TFRFME(lmode, lm, nkv, nxv, nyv, nzv);
 	for (int i24 = nxshpo; i24 <= nxs; i24++) {
 	  tfrfme->set_x(i24, tfrfme->get_x(i24 - 1) + delxyz);