Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a bug about memory leak in MFC #744

Open
weidoom opened this issue Jul 11, 2024 · 4 comments
Open

a bug about memory leak in MFC #744

weidoom opened this issue Jul 11, 2024 · 4 comments

Comments

@weidoom
Copy link

weidoom commented Jul 11, 2024

Hi
I use xlnt in visual studio 2022 ,install it from vcpkg.
I create a console app with default template ,and then call xlnt , it works fine.
but i create a MFC console application with default template, even if only defined a workbook object,there will be a lot of memory leak. like this:
int main()
{
xlnt::workbook wb;
return 0;
}
when I create a windows desktop app, xlnt works fine! but if create a MFC windows desktop app, there will be a lot of memory leak.

@flaviu22
Copy link

"MFC console application"
I don't know how you did that, a MFC app is a Windows application, not console, can you put here your steps to reproduce this issue?
And you are sure if those memory leaks are from xlnt, or MFC app itself?

@weidoom
Copy link
Author

weidoom commented Jul 15, 2024

"MFC console application " mean Create a console application with MFC headers;
the step is:
In Visual studio 2022

  1. Create a new project
  2. select" Windows Desktop Wizard"
    3.Application type select "Console Application(.exe)"
    4.Select "MFC headers"
    like this:
    MFC

I'm guessing it's because xlnt and mfc are a little incompatible.
because create a console application without MFC header ,it work fine ,like this;
NoMemoryLeakNoMFC
If create a console application with MFC header, it cause a lot of memory leak,like this:
MemoryLeak
If I comment xlnt , there is no any memory leak,like this:
NoMemoryLeak

if i use xlnt in console application with MFC header, I had to modify the numeric.hpp header file, otherwise it wouldn't compile successfully. including the max and min functions。add a bracket.

constexpr typename std::common_type<NumberL, NumberR>::type max(NumberL lval, NumberR rval)
{
return (lval < rval) ? rval : lval;
}
--->
template <typename NumberL, typename NumberR>
constexpr typename std::common_type<NumberL, NumberR>::type (max)(NumberL lval, NumberR rval)
{
return (lval < rval) ? rval : lval;
}

template <typename NumberL, typename NumberR>
constexpr typename std::common_type<NumberL, NumberR>::type min(NumberL lval, NumberR rval)
{
return (lval < rval) ? lval : rval;
}
--》
template <typename NumberL, typename NumberR>
constexpr typename std::common_type<NumberL, NumberR>::type (min)(NumberL lval, NumberR rval)
{
return (lval < rval) ? lval : rval;
}

@weidoom
Copy link
Author

weidoom commented Jul 15, 2024

In addition I did the following testcase:
I created a standard DLL that exports a function ,for example , void Test();, in the function I called xlnt , it works fine in a console application, but if I call this DLL in an MFC console application it causes a lot of memory leak.

@weidoom
Copy link
Author

weidoom commented Jul 15, 2024

I think this bug is not focused on MFC console application.
In VS 2022,if I create any windows desktop application without mfc and call xlnt, it works fine,
if create any windows desktop application with MFC, there will cause memory leak!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants