          globalParams = new GlobalParams();
          setErrorCallback(detail::error_function, NULL);
      }
-@@ -662,3 +664,65 @@ document* document::load_from_raw_data(const char *file_data,
+@@ -662,3 +664,71 @@ document* document::load_from_raw_data(const char *file_data,
                                  owner_password, user_password);
      return document_private::check_document(doc, 0);
  }

+  delete doc_;
+  printf("~smpledoc: %d\n", __LINE__);
+  doc_ = NULL;
+  printf("~smpledoc: %d\n", __LINE__);
+  //delete stream_;
+  printf("~smpledoc: %d\n", __LINE__);
+  stream_ = NULL;
+  printf("~smpledoc: %d\n", __LINE__);
+  delete[] buf_copy_;
+  printf("~smpledoc: %d\n", __LINE__);

 namespace poppler
 {
 
@@ -99,6 +105,23 @@ private:
     friend class document_private;
 };
 
