---
name: "vm_map_find"
section: "9"
platform: "linux"
package: "freebsd-manpages"
version: "6.0-5"
release: "Debian 4.0 (Etch)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/vm_map_find"
---

# vm\_map\_find(9)

find a free region within a map, and optionally map a vm\_object

## NAME

**vm\_map\_find** – find a free region within a map, and optionally map a vm\_object

## SYNOPSIS

**#include \<sys/param.h\>**

**#include \<vm/vm.h\>**

**#include \<vm/vm\_map.h\>**

*int*\

**vm\_map\_find**(*vm\_map\_t map*, *vm\_object\_t object*, *vm\_ooffset\_t offset*, *vm\_offset\_t \*addr*, *vm\_size\_t length*, *boolean\_t find\_space*, *vm\_prot\_t prot*, *vm\_prot\_t max*, *int cow*);

## DESCRIPTION

The **vm\_map\_find**() function attempts to find a free region in the target *map*, with the given *length*, and will also optionally create a mapping of *object*.

The arguments *offset*, *prot*, *max*, and *cow* are passed unchanged to [vm\_map\_insert(9)](/vm_map_insert/9.md) when creating the mapping, if and only if a free region is found.

If *object* is non-NULL, the reference count on the object must be incremented by the caller before calling this function to account for the new entry.

If *find\_space* is TRUE, the function will call [vm\_map\_findspace(9)](/vm_map_findspace/9.md) to discover a free region.

## IMPLEMENTATION NOTES

This function acquires a lock on *map* by calling [vm\_map\_lock(9)](/vm_map_lock/9.md), and holds it until the function returns.

The search for a free region is defined to be first-fit, from the address *addr* onwards.

## RETURN VALUES

The **vm\_map\_find**() function returns KERN\_SUCCESS if space for the mapping could be found and the mapping was successfully created. If space could not be found in the map, KERN\_NO\_SPACE will be returned. If the discovered range turned out to be bogus, KERN\_INVALID\_ADDRESS will be returned.

## SEE ALSO

[vm\_map(9)](/vm_map/9.md), [vm\_map\_findspace(9)](/vm_map_findspace/9.md), [vm\_map\_insert(9)](/vm_map_insert/9.md), [vm\_map\_lock(9)](/vm_map_lock/9.md)

## AUTHORS

This manual page was written by Bruce M Simpson ⟨bms@spc.org⟩.
