Skip to content
This repository was archived by the owner on Nov 25, 2019. It is now read-only.
This repository was archived by the owner on Nov 25, 2019. It is now read-only.

Remove reference-types from structs #63

@david-rhodes

Description

@david-rhodes

From Unity documentation:

The way that our code is structured can impact garbage collection. Even if our code does not create heap allocations, it can add to the garbage collector’s workload.

One way that our code can unnecessarily add to the garbage collector’s workload is by requiring it to examine things that it should not have to examine. Structs are value-typed variables, but if we have a struct that contains contains a reference-typed variable then the garbage collector must examine the whole struct. If we have a large array of these structs, then this can create a lot of additional work for the garbage collector.

Tile.Parameters:

// I'm a struct . . .
public struct Parameters 
{
	public CanonicalTileId Id;

        // but I contain reference-types :(
	public string MapId;
	public IFileSource Fs;
}

Solution: pass these parameters in the constructor?

Response:

public struct Response
{
       // reference-types
	public string Error;
	public Dictionary<string, string> Headers;

	public byte[] Data;
}

Solution: Handle errors with a different pattern. Do we even use Headers?

/cc @brnkhy @isiyu @MateoV @BergWerkGIS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions