# Huge files and network shares

## Huge files

TKTail is made for logs of many gigabytes. It never reads a whole file into memory: what you see is read when
you look at it, and memory stays small whatever the size.

*Screenshot: A 300 MB log at 150 MB: line numbers from the index, 3,960,000 lines*

- **Opening** does not read the file through: TKTail shows its end (LIVE) or its start (`--paused`) right away
  and builds the line index in the background.
- **The scroll bar** maps to the position in bytes, so it works the same for 1 KB and 100 GB. **Ctrl+G** goes
  to a line or a byte offset (`8GB` works); `tktail open huge.log --offset 8GB` from the command line.
- **Line numbers** are exact. For a very large file they appear once the background **line index** has reached
  that part of the file. Files up to 16 GB are indexed automatically (Settings > Monitoring > *Build the full
  line index automatically for files up to*); **View > Build Full Line Index** indexes any file on request.
  The status bar shows the index's progress.
- **Search** runs in the background in slices - the window never freezes, and Find shows *counting 42%* while
  it counts. **Esc** cancels a search; what it found stays.
- **Record times**: Go To Time and the Inspector use the times of the records already read; **View > Read the
  File's Times** reads the rest of the file's times in the background ([Records and time](https://tktail.dev/help/viewing-logs/#records-and-time)).
- **Long lines** stay one line: a record of hundreds of kilobytes wraps as one paragraph; only lines longer
  than 1 MB continue on a new row every megabyte.

## Files on network shares

A local file tells TKTail when it changes (Windows sends a notification), and TKTail also checks
it four times a second - that is **LIVE**. A file on a network share (a `\\server\share\...` path
or a mapped drive letter) often does not: shares deliver notifications late, merge them or send
none, and a server may report the new size only after its write cache is flushed. So TKTail
**checks** network files. A check asks only for the file's size; nothing is read until the file
has grown, and then only the new bytes.

How a file is followed is its **refresh mode** - in the Inspector, **Monitoring > Refresh** (click
the value, or **...** > **Change Refresh Mode...**):

| Mode | What TKTail does | Status bar |
|---|---|---|
| **Auto** (default) | A local file: notifications and a check every 250 ms (every 2 s while TKTail is hidden in the tray). A network file: notifications where the share sends them, and checks every second after a change, slowing down step by step (2, 5, 10 s) to every 30 s while nothing changes | `LIVE` (local), `AUTO 1 s` ... `AUTO 30 s` (network) |
| **Event** | Notifications only - the file itself is never checked; the lowest cost. Windows may report a change only when the writer's data reaches the disk, and some shares accept the request but never report a change; there new lines do not appear on their own (choose Auto or Poll). When notifications stop working (the share went away, the folder is gone), the status bar says `NO EVENTS`: TKTail only checks whether the folder can be reached again (after 1, 2, 5 ... s, at most every minute), restores the notifications and then catches up | `LIVE`, `NO EVENTS` |
| **Poll** | Checks at the interval you choose - 500 ms, 1, 2, 5, 10, 20 or 30 s, 1, 2, 5, 10, 15 or 30 min, 1 h - and no notifications. New lines appear within about that interval | `POLL 5 s` |

The Inspector also shows how changes are detected now, whether the file is on a network share,
the connection, and when TKTail last checked and last saw a change. Your choice is remembered for
the file's tab when TKTail restores your workspace, and for a file monitored in the background
([Alerts and monitoring](https://tktail.dev/help/alerts-and-monitoring/#monitoring-files-in-the-background)).
**PAUSED** stops only the view: the file is still checked, its new lines are read and your alerts
see them.

**When the share cannot be reached** (the server is down, the VPN dropped, the drive was
disconnected), the status bar shows **OFFLINE** and the tab says so; the lines already shown
stay. TKTail tries again after 1, 2, 5, 10 and 30 seconds and then every minute
(**RECONNECTING** while a try is under way). When the share is back, TKTail continues where it
was and reads only what was added meanwhile; a file that was replaced or deleted in the
meantime is handled like a rotation or a missing file; a log with the date in its name goes on to the newest file
of its series ([Rotating dated log files](https://tktail.dev/help/rotating-dated-logs/#files-on-network-shares)). A file deleted on a share that *can* be
reached is shown as missing, not offline. One slow or dead server never holds up your other
files.

---

The HTML page: https://tktail.dev/help/large-and-network-files/
