Skip to content

Conversation

@pejovica
Copy link
Member

This PR adds a copy-on-write image heap provider for Windows.

A few high-level notes on implementation:

  • New image heaps are provided by memory mapping views of the loaded image heap.
  • In case of failure to map a new image heap, the implementation falls back to copying from memory as before.
  • For memory mapping to work, the OS must have support for memory placeholders. This is checked at runtime as not all Windows versions have the necessary support.
  • The use of memory placeholders is transparent to the rest of the system, i.e., it is completely encapsulated in WindowsVirtualMemoryProvider .

@pejovica pejovica added this to the 22.0 milestone Nov 24, 2021
@pejovica pejovica requested a review from peter-hofer November 24, 2021 13:32
@graalvmbot graalvmbot merged commit 5373664 into master Nov 24, 2021
@pejovica pejovica deleted the github/ap/GR-21865-copy-on-write branch November 25, 2021 12:28
@joerg-wille
Copy link

This PR breaks compatibility with upx.
It is desirable to achieve minimum app size for which upx is commonly used to compress nativ Image.

Some ideas for a more proper fix:

  • Compare the static parts of the in-memory image heap with the mapped file and fall back to super.commitAndCopyMemory when not matching
  • Create a paging file backed (INVALID_HANDLE_VALUE) file mapping object, copy the uncompressed image heap to it and then that can be used and shared the same way as the mapped executable file

Originally posted by @kornelpal in upx/upx#559 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants