I see sometimes see very high memory consumption when selecting from SQL Server ntext columns.
I think it might be triggered when the tables are empty.
The script below was run on Ubuntu 16.04 with turbodbc 1.1.0 and mssql-server 14.0.405.200-1.
massif output shows an heap allocation of 2GB, turning on use_async_io doubles the usage to 4GB.
The memory usage starts at snapshot 63, so I am not use if the stack trace in snapshot 64 is relevant.
(massif-visualizer is useful for visualizing)
#-----------
snapshot=62
#-----------
time=63680421
mem_heap_B=1951776
mem_heap_extra_B=74400
mem_stacks_B=0
heap_tree=empty
#-----------
snapshot=63
#-----------
time=298830808
mem_heap_B=2149397260
mem_heap_extra_B=78044
mem_stacks_B=0
heap_tree=empty
#-----------
snapshot=64
#-----------
time=298844168
mem_heap_B=2149401564
mem_heap_extra_B=78108
mem_stacks_B=0
heap_tree=peak
n2: 2149401564 (heap allocation functions) malloc/new/new[], --alloc-fns, etc.
n1: 2147483648 0x69C6911: cpp_odbc::multi_value_buffer::multi_value_buffer(unsigned long, unsigned long) (new_allocator.h:104)
n1: 2147483648 0x69CFE23: turbodbc::column::column(cpp_odbc::statement const&, unsigned long, unsigned long, std::unique_ptr<turbodbc::description const, std::default_delete<turbodbc::description const> >) (column.cpp:9)
n1: 2147483648 0x69D5EB2: void std::vector<turbodbc::column, std::allocator<turbodbc::column> >::_M_emplace_back_aux<cpp_odbc::statement const&, unsigned long&, unsigned long&, std::unique_ptr<turbodbc::description const, std::default_delete<turbodbc::description const> > >(cpp_odbc::statement const&, unsigned long&, unsigned long&, std::unique_ptr<turbodbc::description const, std::default_delete<turbodbc::description const> >&&) (new_allocator.h:120)
n1: 2147483648 0x69D5991: turbodbc::result_sets::bound_result_set::bound_result_set(std::shared_ptr<cpp_odbc::statement const>, boost::variant<turbodbc::rows, turbodbc::megabytes>, bool) (vector.tcc:101)
n1: 2147483648 0x69CE8CD: turbodbc::command::execute() (new_allocator.h:120)
n1: 2147483648 0x69CD072: turbodbc::cursor::execute() (cursor.cpp:58)
n1: 2147483648 0x67852F3: void pybind11::cpp_function::initialize<pybind11::cpp_function::initialize<void, turbodbc::cursor, , pybind11::name, pybind11::is_method, pybind11::sibling>(void (turbodbc::cursor::*)(), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&)::{lambda(turbodbc::cursor*)#1}, void, turbodbc::cursor*, pybind11::name, pybind11::is_method, pybind11::sibling>(pybind11::cpp_function::initialize<void, turbodbc::cursor, , pybind11::name, pybind11::is_method, pybind11::sibling>(void (turbodbc::cursor::*)(), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&)::{lambda(turbodbc::cursor*)#1}&&, void (*)(turbodbc::cursor*), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&)::{lambda(pybind11::detail::function_record*, pybind11::handle, pybind11::detail::function_record*, pybind11::detail::function_record*)#3}::_FUN(pybind11::detail::function_record, pybind11::detail::function_record*, pybind11::detail::function_record*, pybind11::detail::function_record*) (pybind11.h:62)
n1: 2147483648 0x677F025: pybind11::cpp_function::dispatcher(_object*, _object*, _object*) (pybind11.h:441)
n1: 2147483648 0x4CADA0: PyEval_EvalFrameEx (in /usr/bin/python2.7)
n1: 2147483648 0x4C2763: PyEval_EvalCodeEx (in /usr/bin/python2.7)
n1: 2147483648 0x4DE8B6: ??? (in /usr/bin/python2.7)
n1: 2147483648 0x4B0CB1: PyObject_Call (in /usr/bin/python2.7)
n1: 2147483648 0x4C6ACF: PyEval_EvalFrameEx (in /usr/bin/python2.7)
n1: 2147483648 0x4C2763: PyEval_EvalCodeEx (in /usr/bin/python2.7)
n1: 2147483648 0x4CA8CF: PyEval_EvalFrameEx (in /usr/bin/python2.7)
n1: 2147483648 0x4C2763: PyEval_EvalCodeEx (in /usr/bin/python2.7)
n1: 2147483648 0x4C2507: PyEval_EvalCode (in /usr/bin/python2.7)
n1: 2147483648 0x4F1DED: ??? (in /usr/bin/python2.7)
n1: 2147483648 0x4EC650: PyRun_FileExFlags (in /usr/bin/python2.7)
n1: 2147483648 0x4EAE2F: PyRun_SimpleFileExFlags (in /usr/bin/python2.7)
n1: 2147483648 0x49E148: Py_Main (in /usr/bin/python2.7)
n0: 2147483648 0x506E82E: (below main) (libc-start.c:291)
n0: 1917916 in 361 places, all below massif's threshold (1.00%)
#-----------
snapshot=65
#-----------
time=300787456
mem_heap_B=2149388856
mem_heap_extra_B=78032
mem_stacks_B=0
heap_tree=empty
#-----------