---
title: synchronize()
framework: foundation
role: symbol
role_heading: Instance Method
path: foundation/filehandle/synchronize()
---

# synchronize()

Causes all in-memory data and attributes of the file represented by the file handle to write to permanent storage.

## Declaration

```swift
func synchronize() throws
```

## Discussion

Discussion Programs that require the file to always be in a known state should call this method. An invocation of this method doesn’t return until memory is flushed.

## See Also

### Operating on a file

- [close()](foundation/filehandle/close().md)
- [truncate(atOffset:)](foundation/filehandle/truncate(atoffset:).md)
