Created
February 1, 2023 14:15
-
-
Save tomwhoiscontrary/ed1aa41e6c95867b405ae59ad480b4de to your computer and use it in GitHub Desktop.
source code for " Memory leak in SofrFutureRateHelper" https://github.com/lballabio/QuantLib/issues/1578
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ql/config.hpp. Generated from config.hpp.in by configure. */ | |
/* ql/config.hpp.in. Generated from configure.ac by autoheader. */ | |
/* Define to 1 if you have the <dlfcn.h> header file. */ | |
#define HAVE_DLFCN_H 1 | |
/* Define to 1 if you have the <inttypes.h> header file. */ | |
#define HAVE_INTTYPES_H 1 | |
/* Define to 1 if you have the <memory.h> header file. */ | |
#define HAVE_MEMORY_H 1 | |
/* Define to 1 if you have the <stdint.h> header file. */ | |
#define HAVE_STDINT_H 1 | |
/* Define to 1 if you have the <stdlib.h> header file. */ | |
#define HAVE_STDLIB_H 1 | |
/* Define to 1 if you have the <strings.h> header file. */ | |
#define HAVE_STRINGS_H 1 | |
/* Define to 1 if you have the <string.h> header file. */ | |
#define HAVE_STRING_H 1 | |
/* Define to 1 if you have the <sys/stat.h> header file. */ | |
#define HAVE_SYS_STAT_H 1 | |
/* Define to 1 if you have the <sys/types.h> header file. */ | |
#define HAVE_SYS_TYPES_H 1 | |
/* Define to 1 if you have the <unistd.h> header file. */ | |
#define HAVE_UNISTD_H 1 | |
/* Define to the sub-directory in which libtool stores uninstalled libraries. | |
*/ | |
#define LT_OBJDIR ".libs/" | |
/* Name of package */ | |
#define PACKAGE "QuantLib" | |
/* Define to the address where bug reports for this package should be sent. */ | |
#define PACKAGE_BUGREPORT "[email protected]" | |
/* Define to the full name of this package. */ | |
#define PACKAGE_NAME "QuantLib" | |
/* Define to the full name and version of this package. */ | |
#define PACKAGE_STRING "QuantLib 1.29" | |
/* Define to the one symbol short name of this package. */ | |
#define PACKAGE_TARNAME "QuantLib" | |
/* Define to the home page for this package. */ | |
#define PACKAGE_URL "" | |
/* Define to the version of this package. */ | |
#define PACKAGE_VERSION "1.29" | |
/* Define this if you want to enable the parallel unit test runner. */ | |
/* #undef QL_ENABLE_PARALLEL_UNIT_TEST_RUNNER */ | |
/* Define this if you want to enable sessions. */ | |
/* #undef QL_ENABLE_SESSIONS */ | |
/* Define this if you want to enable thread-safe observer pattern. */ | |
/* #undef QL_ENABLE_THREAD_SAFE_OBSERVER_PATTERN */ | |
/* Define this if tracing messages should allowed (whether they are actually | |
emitted will depend on run-time settings.) */ | |
/* #undef QL_ENABLE_TRACING */ | |
/* Define this if error messages should include current function information. | |
*/ | |
/* #undef QL_ERROR_FUNCTIONS */ | |
/* Define this if error messages should include file and line information. */ | |
#define QL_ERROR_LINES 1 | |
/* Define this if extra safety checks should be performed. This can degrade | |
performance. */ | |
/* #undef QL_EXTRA_SAFETY_CHECKS */ | |
/* Define this if you want to enable high resolution date class. */ | |
/* #undef QL_HIGH_RESOLUTION_DATE */ | |
/* Define this if you want to enable the implementation of Null as template | |
functions. */ | |
/* #undef QL_NULL_AS_FUNCTIONS */ | |
/* Define if running on a Sun Solaris machine. */ | |
/* #undef QL_PATCH_SOLARIS */ | |
/* Define this to use indexed coupons instead of par coupons in floating legs. | |
*/ | |
#define QL_USE_INDEXED_COUPON 1 | |
/* Define this if you want to use std::function and std::bind. */ | |
#define QL_USE_STD_FUNCTION 1 | |
/* Define this if you want to use standard smart pointers. */ | |
#define QL_USE_STD_SHARED_PTR 1 | |
/* Define this if you want to use std::tuple. */ | |
#define QL_USE_STD_TUPLE 1 | |
/* Define to 1 if you have the ANSI C header files. */ | |
#define STDC_HEADERS 1 | |
/* Version number of package */ | |
#define VERSION "1.29" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ (ulimit -v 100000; LD_LIBRARY_PATH=native/build/lib ./native/build/src/test/c/leak_demo | wc -l) | |
terminate called after throwing an instance of 'std::bad_alloc' | |
what(): std::bad_alloc | |
264929 | |
$ (ulimit -v 200000; LD_LIBRARY_PATH=native/build/lib ./native/build/src/test/c/leak_demo | wc -l) | |
terminate called after throwing an instance of 'std::bad_alloc' | |
what(): std::bad_alloc | |
797736 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ql/config.hpp> | |
#include <cmath> | |
#include <iostream> | |
#include <ql/settings.hpp> | |
#include <ql/termstructures/yield/overnightindexfutureratehelper.hpp> | |
#include <ql/time/date.hpp> | |
#include <ql/time/frequency.hpp> | |
using std::cout; | |
using std::nan; | |
using QuantLib::Date; | |
using QuantLib::Frequency; | |
using QuantLib::Month; | |
using QuantLib::Settings; | |
using QuantLib::SofrFutureRateHelper; | |
using QuantLib::io::iso_date; | |
int main(int argc, char** argv) { | |
Settings::instance().evaluationDate() = Date(31, Month::January, 2023); | |
Date valueDate(15, Month::March, 2023); | |
while (true) { | |
SofrFutureRateHelper helper(nan(""), valueDate.month(), valueDate.year(), Frequency::Quarterly, nan("")); | |
Date maturityDate = helper.maturityDate(); | |
cout << iso_date(valueDate) << " -> " << iso_date(maturityDate) << "\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment