title: Discarding DLL's resource after using it
body: <p>I'm creating a dll with an embedded binary resource. Currently when I load this DLL it gets memory mapped into my process address space. The problem is that the embedded binary resource is huge and I don't want to keep it around once I'm done using it.</p>
  
  <p>I tried looking up documentation regarding this and apparently there are sections in the PE file which don't get memory mapped(relocation section). Also, I can create new sections and flag it IMAGE_SCN_MEM_DISCARDABLE but this flag is ignored outside of kernel mode. </p>
  
  <p>There was a win API function which supported freeing resources for 16-bit Windows but doesn't work 32-bit onward. The <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms648044%28v=vs.85%29.aspx" rel="nofollow">documentation</a> says "This function is obsolete and is only supported for backward compatibility with 16-bit Windows. For 32-bit Windows applications, it is not necessary to free the resources loaded using LoadResource. If used on 32 or 64-bit Windows systems, this function will return FALSE". I don't know what they mean by that but it seems like they don't expect resources to be huge and can be accommodated in the address space.</p>
  
  <p>Is there any way for me to keep discard the resources I load after I'm done using them?</p>