Skip to content

Instantly share code, notes, and snippets.

@joeduffy
joeduffy / tear.go
Created July 17, 2015 22:24
Breaking Go memory safety by violating concurrency safety.
// tear.go
// A simple demonstration of breaking Go memory safety by violating concurrency
// safety. We alias a shared slice variable -- which is a multi-word variable --
// and then reads/write that shared variable in parallel between Goroutines.
// If "torn slice: ..." is printed, something VeryBad(tm) has occurred...
package main
import (
"fmt"
"runtime"
@joeduffy
joeduffy / teariface.go
Created July 18, 2015 15:40
Breaking Go memory safety by violating concurrency safety (#2: interfaces).
// teariface.go
// A simple demonstration of breaking Go memory safety by violating concurrency
// safety. We alias an interface variable which is of course multiple words;
// the net result is the itable pointer and target object pointer end up
// mismatched, triggering undefined behavior (wrong results, AVs, etc).
package main
import (
"fmt"
"runtime"

eager sweep, non-conc

world stop
     1
value  ------------- Distribution ------------- count    
   64 |                                         0        
  128 |@                                        1        
  256 |                                         0        
  512 |                                         0        
 1024 |                                         0        
@moebio
moebio / gist:5601071
Last active December 17, 2015 11:19
list of references of my talk at http://openvisconf.com
@Clancey
Clancey / BrightlyBlurredUIView
Last active December 24, 2015 14:59
A brightly colored iOS 7 UIBlurView
using System;
using MonoTouch.UIKit;
using MonoTouch.CoreAnimation;
public class BrightlyBlurredUIView: UIView
{
CALayer blurLayer,accentLayer;
UIView accentView;
UIToolbar toolbar;
public BrightlyBlurredUIView()
using System;
using System.Net;
using System.Reflection;
namespace UriTest
{
//a mono version of the ForceCanonicalPathAndQuery code here: http://stackoverflow.com/questions/781205/getting-a-url-with-an-url-encoded-slash
class Program
{
static void Main(string[] args)
import Darwin.C
import Venice
struct SubProcess {
let path: String
let arguments: [String]
func run(sync sync: Bool = true) -> Int? {
@praeclarum
praeclarum / EasyLayout.fs
Last active August 23, 2020 09:52
EasyLayout makes writing auto layout code in Xamarin.iOS F# easier.
module EasyLayout
open System
open System.Drawing
open Microsoft.FSharp.Quotations
open Microsoft.FSharp.Quotations.Patterns
open Microsoft.FSharp.Quotations.DerivedPatterns
open MonoTouch.Foundation
open MonoTouch.UIKit
@munificent
munificent / gist:9749671
Last active June 23, 2022 04:04
You appear to be creating a new IDE...
You appear to be advocating a new:
[ ] cloud-hosted [ ] locally installable [ ] web-based [ ] browser-based [ ] language-agnostic
[ ] language-specific IDE. Your IDE will not succeed. Here is why it will not succeed.
You appear to believe that:
[ ] Syntax highlighting is what makes programming difficult
[ ] Garbage collection is free
[ ] Computers have infinite memory
[ ] Nobody really needs:
@iOSappssolutions
iOSappssolutions / FB11835461.md
Last active May 12, 2023 13:44
NavigationStack creates memory leak if Hashable referrence type is used for path

FB11835461

In real world applications it makes more sense to use ObservableObject referrence type to drive navigation than simple value type. The example below demonstrates that.

Problem is that for some reason NavigationStack will create memory leak if path is set to empty array after navigating any number of times through stack. All view models that were created in process will be retained in memory even though path is set to [].

Same problem occurs if we set path to empty array and just swap whole NavigationStack with any other view still all objects created will be retained in memory.

There is workaround that I will show bellow to fix this but it is still very buggy behaviour IMO.