Why do we unmap memory rigth after mapping it? Isn't it that we are holding data in this address?
void* data;
vkMapMemory(device, stagingBufferMemory, 0, imageSize, 0, &data);
memcpy(data, pixels, static_cast<size_t>(imageSize));
vkUnmapMemory(device, stagingBufferMemory);
Example code from Vulkan Doc
Sorry for this "child-like" question for beginner in cg. Need to clarify it.
Example code from vulkan docs
That's the key element here: they give you a complete example -- map the memory, copy the data, unmap the memory.
Keep in mind that mapping memory will consume virtual address space on your process. This might not be such a big deal in a 64-bit world, but...
As for real-life applications, it's up to the application developer to decide whether they want to keep the mapping (because they want to use it again) or not.