Copy link to clipboard
Copied
Hi,
I have some UI related memory leaks in our C++ plugin.
I would like to free the allocated memory under application close.
In the StartupShutdown -> Shutdown function UI elements are down so I cannot reach them.
Could you give me some advice me how can I catch the best moment to free these UI allocated memory.
Thx
Karoly
Hi Karoly,
Ah, I see, your plugin does not close InDesign, the user does. Our plugin does not respod to user actions, as it takes control and runs in batch mode.
If you know where the leaks occur, can you not refactor the code so that the new() and delete() are in the same scope ? What kind of leaks are there ?
Very best regards,
Olivier
Copy link to clipboard
Copied
Hi Karoly,
You might want to try DeLeaker (https://www.deleaker.com/blog/2020/01/04/how-to-check-for-memory-leaks-in-visual-studio/) or this thread on Stack Overflow (https://stackoverflow.com/questions/4790564/finding-memory-leaks-in-a-c-application-with-visual-stud....
Very best regards,
Olivier
Copy link to clipboard
Copied
Hi Oliver,
Thank you for your answer.
I have already mapped out the memory leaks.
I use pmruntime.dll from MemoryTracker folder.
I would like to free the allocated memory under application closing process.
I don't know how can I get the UI closing function (like StartupShutdown -> ShutDown()) to free these UI allocated memory.
Best Regards
Karoly
Copy link to clipboard
Copied
Hi Karoly,
Sorry I misread your post.
I put all my clean-up code just before (or inside) my function that shutsdown InDesign.
void IppIDUtilities::IppQuitIndesign()
{
// Create a QuitCmd:
InterfacePtr<ICommand> quitCmd(CmdUtils::CreateCommand(kQuitCmdBoss));
// Schedule the QuitCmd (Note: ProcessCommand not used with QuitCmd):
CmdUtils::ScheduleCommand(quitCmd);
}
Very best regards,
Olivier
Copy link to clipboard
Copied
Hi Oliver,
Could you explain in more deatil?
- Where should I add my cleaning code?
- Need I call direct the IppIDUtilities::IppQuitInDesign() and create the scheduled quitCmd command under Startup?
Thx
Karoly
Copy link to clipboard
Copied
Hi Karoly,
I am assuming that your PLN:
Is that not the case ?
Very best regards,
Olivier
Copy link to clipboard
Copied
Hi Oliver,
Yes,
1. Our plugin loading when InDesign start. StartupShutdown -> Starup()
2. We does something (generate documents with data from an app server)
3. Close InDesign
Best Regards
Karoly
Copy link to clipboard
Copied
Hi Olivier,
I ask the question differently:
How can I catch File -> Exit event?
Best Regards
Karoly
Copy link to clipboard
Copied
Hi Karoly,
Ah, I see, your plugin does not close InDesign, the user does. Our plugin does not respod to user actions, as it takes control and runs in batch mode.
If you know where the leaks occur, can you not refactor the code so that the new() and delete() are in the same scope ? What kind of leaks are there ?
Very best regards,
Olivier
Copy link to clipboard
Copied
Hi Olivier,
Maybe refactoring the solution.
That's what I was thinking.
We have 2-3 UI related classes with container that contains vectors with dinamically allocated elements.
I can move these containers to en other class if we don't have a better idea 🙂
Thak you for your time and patience.
Best Regards
Karoly