<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Dec 10, 2014 at 1:45 PM, Ivan Koster <span dir="ltr"><<a href="mailto:ivankoster@gmail.com" target="_blank">ivankoster@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">From <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa366537(v=vs.85).aspx" target="_blank">http://msdn.microsoft.com/en-us/library/windows/desktop/aa366537(v=vs.85).aspx</a><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span style="color:rgb(69,69,69);font-family:'Segoe UI','Lucida Grande',Verdana,Arial,Helvetica,sans-serif;font-size:14px;line-height:20.0060005187988px">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 </span><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa366882(v=vs.85).aspx" style="text-decoration:none;font-family:'Segoe UI Semibold','Segoe UI','Lucida Grande',Verdana,Arial,Helvetica,sans-serif;font-size:14px;line-height:20.0060005187988px;color:rgb(0,24,143)" target="_blank"><strong>UnmapViewOfFile</strong></a><span style="color:rgb(69,69,69);font-family:'Segoe UI','Lucida Grande',Verdana,Arial,Helvetica,sans-serif;font-size:14px;line-height:20.0060005187988px"> and close the file mapping object handle by calling </span><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms724211(v=vs.85).aspx" style="text-decoration:none;font-family:'Segoe UI Semibold','Segoe UI','Lucida Grande',Verdana,Arial,Helvetica,sans-serif;font-size:14px;line-height:20.0060005187988px;color:rgb(0,24,143)" target="_blank"><strong>CloseHandle</strong></a><span style="color:rgb(69,69,69);font-family:'Segoe UI','Lucida Grande',Verdana,Arial,Helvetica,sans-serif;font-size:14px;line-height:20.0060005187988px">. These functions can be called in any order.</span></blockquote><font color="#454545" face="Segoe UI, Lucida Grande, Verdana, Arial, Helvetica, sans-serif"><span style="font-size:14px;line-height:20.0060005187988px"><br></span></font>Since CloseHandle is already called after the init, it seems the mapped view is still open?<br>I'm a C and python programmer and (no C++ experience at all) have an incredible hard time reading the code.<div>Nevertheless, Mapping in mapped_file_region seems to be the only view created and it is unmapped in the destructor:<br></div><div><div><div><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">mapped_file_region::~mapped_file_region() {<br>  if (Mapping)<br>    ::UnmapViewOfFile(Mapping);<br>}</blockquote><div><br></div><div>Can I conclude that the destructor is not called?</div></div></div></div></div></blockquote><div><br></div><div>In normal compilation, the file remains mapped into memory until compilation is over. Sometimes the AST has pointers to string data embedded in the code. In YCM, I guess compilation is never "over" so the file stays mapped indefinitely.</div><div><br></div><div>We need to figure out a file mapping strategy that will work on Windows. On Linux, there are no file locks, and "well behaved" editors generally save files atomically by writing a temp file and renaming it over the original file. I don't know what editors on Windows do. If popular editors (Notepad+, VS, sublime, Vim, etc) rewrite the file in place, then we might have to give up on the mmap approach, as it will be racy.</div></div></div></div>