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

HPCC-20188 Fix 3 memory leaks #11915

Merged
merged 1 commit into from
Nov 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions esp/services/ws_machine/ws_machineService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,8 @@ unsigned Cws_machineEx::addRoxieStateHash(const char* hash, StateHashes& stateHa
{
//Add a new 'StateHash'. Set its hashID to totalUniqueHashes and set its count to 1.
hashID = totalUniqueHashes;
stateHashes.setValue(hash, new CStateHash(hashID, 1));
Owned<IStateHash> newStateHash = new CStateHash(hashID, 1);
stateHashes.setValue(hash, newStateHash);
totalUniqueHashes++;
}
return hashID;
Expand Down Expand Up @@ -1180,7 +1181,7 @@ int Cws_machineEx::runCommand(IEspContext& context, const char* sAddress, const
if (command.length() < 1)
return exitCode;

IFRunSSH * connection = createFRunSSH();
Owned<IFRunSSH> connection = createFRunSSH();
connection->init(command.str(),NULL,NULL,NULL,m_SSHConnectTimeoutSeconds,0);
// executed as single connection
connection->exec(sAddress,NULL,true);
Expand Down
7 changes: 7 additions & 0 deletions system/jlib/jfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6239,6 +6239,13 @@ class CMemoryMappedFile: implements IMemoryMappedFile, public CInterface
CloseHandle(hfile);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be consistent, for WIN32, is UnmapViewOfFile() needed here or is it enough to CloseHandle(hmap) ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ghalliday Can you comment?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good thinking, I think you are correct . From the documentation:

"Mapped views of a file mapping object maintain internal references to the object, and a file mapping object does not close until all references to it are released. Therefore, to fully close a file mapping object, an application must unmap all mapped views of the file mapping object by calling UnmapViewOfFile and close the file mapping object handle by calling CloseHandle. These functions can be called in any order."

the same goes for the existing code in reinit() on line 6308.

@wangkx

#else
close(hfile);
#endif
#if defined(__linux__)
if (ptr)
{
munmap(realptr(),realsize());
ptr = NULL;
}
#endif
}

Expand Down