Skip to content

Instantly share code, notes, and snippets.

View joscdk's full-sized avatar

Jonas Schwartz joscdk

View GitHub Profile

It often be helpful to be able to debug memory usage in Swift on Linux, for example to debug memory leaks.

This is a quick overview of how to generate a report of memory usage for your Swift app. This guide will only show you how to generate the report, not how to analyze it, it might be written up in a blog post later.

Install Valgrind

First we need to install a tool called Valgrind, which is used to trace memory usage.

@joscdk
joscdk / env.md
Created December 5, 2018 14:45
Using .env files in Vapor 3

.env files can be an easy way to setup Environment variables locally. You can start using a .env files in Vapor 3 by following this small guide.

First setup the vapor-ext package in your Package.swift file:

.package(url: "https://github.com/vapor-community/vapor-ext.git", from: "0.1.0"),

Next create a .env file in the root of your project:

var databases = DatabasesConfig()
let databaseConfig: PostgreSQLDatabaseConfig
if let url = Environment.get("DB_POSTGRESQL") {
    databaseConfig = try PostgreSQLDatabaseConfig(url: url)
} else {
    // Local configuration
    let hostname = "localhost"
    let username = "vapor"
    let password = "password"
    let database = "vapor"