Memory-Alignment: a tool to help analyze layout of fields in struct in memory

Memory Alignment

Memory-Alignment is a tool to help analyze layout of fields in struct in memory.

Usage

go get github.com/vearne/mem-aligin

Example

package main

import (
	"github.com/vearne/mem-align"
)

type Car struct {
	flag bool
	age  int32
	F1   int8
	F2   int64
	F3   []byte
	Name string
	F4   error
}

func main(){
	memalign.PrintStructAlignment(Car{})
}

Output

output

Owner
vearne
stay foolish stay hungry
vearne
Similar Resources

Code generator to help implement the visitor pattern.

mkvisitor Given package example type ( Node struct{} Leaf struct{} ) run mkvisitor -type "Node,Leaf" then generate package example import "fmt" t

Oct 6, 2021

Homestead - Some tools to help with my homesteading.

Some tools to help with my homesteading. Since I'm based out of the US, I used existing government APIs to develop this. I will likely augment some of

Jan 8, 2022

Poc rsa - A simple golang scaffolding to help me to create new api projects or workers with golang on k8s

go-scaffold A simple golang scaffolding to help me to create new api projects or

Feb 3, 2022

Simple Tools to help manage non-production Kubernetes Clusters

SecondMate.io A tool to help your nonProduction Kubernetes Clusters running clean. The goal of this tool is to add some features to non production clu

Feb 21, 2022

This is a CLI to help changing and doing stuff in Terraform Cloud.

Terraform Cloud Tool This is a CLI to help changing and doing stuff in Terraform Cloud. Terraform CLI Functions $ terraform-cloud-tool Terraform Cloud

Jul 27, 2022

Some useful tools to help manage attachments in my local markdown projects.

Some useful tools to help manage attachments in my local markdown projects.

Oct 8, 2022

Golang-samples - Help someone need some practices when learning golang

GO Language Samples This project is to help someone need some practices when lea

Jan 11, 2022

OpenAIOS vGPU scheduler for Kubernetes is originated from the OpenAIOS project to virtualize GPU device memory.

OpenAIOS vGPU scheduler for Kubernetes is originated from the OpenAIOS project to virtualize GPU device memory.

OpenAIOS vGPU scheduler for Kubernetes English version|中文版 Introduction 4paradigm k8s vGPU scheduler is an "all in one" chart to manage your GPU in k8

Jan 3, 2023

In-memory database package

Go FRM Module In-memory database package Usage Install module in your project: go get github.com/xpartacvs/go-frm Use the packages: package main impo

Dec 25, 2021
Comments
  • 不确定total cost的值是否正确

    不确定total cost的值是否正确

    type A struct { a int b struct{} c string }

    type B struct { a int c string b struct{} }

    func main(){ fmt.Println(unsafe.Sizeof(A{})) memalign.PrintStructAlignment(A{})

    fmt.Println(unsafe.Sizeof(B{}))
    memalign.PrintStructAlignment(B{})
    

    }


    24 ---- Fields in struct ---- +----+-----------+-----------+-----------+ | ID | FIELDTYPE | FIELDNAME | FIELDSIZE | +----+-----------+-----------+-----------+ | A | int | a | 8 | | B | struct {} | b | 0 | | C | string | c | 16 | +----+-----------+-----------+-----------+ ---- Memory layout ---- |A|A|A|A|A|A|A|A| |C|C|C|C|C|C|C|C| |C|C|C|C|C|C|C|C|

    total cost: 24 Bytes.


    32 ---- Fields in struct ---- +----+-----------+-----------+-----------+ | ID | FIELDTYPE | FIELDNAME | FIELDSIZE | +----+-----------+-----------+-----------+ | A | int | a | 8 | | B | string | c | 16 | | C | struct {} | b | 0 | +----+-----------+-----------+-----------+ ---- Memory layout ---- |A|A|A|A|A|A|A|A| |B|B|B|B|B|B|B|B| |B|B|B|B|B|B|B|B|

    total cost: 24 Bytes.

DepCharge is a tool designed to help orchestrate the execution of commands across many directories at once.

DepCharge DepCharge is a tool that helps orchestrate the execution of commands across the many dependencies and directories in larger projects. It als

Sep 27, 2022
Open Source runtime tool which help to detect malware code execution and run time mis-configuration change on a kubernetes cluster
Open Source runtime tool which help to detect malware code execution and run time mis-configuration change on a kubernetes cluster

Kube-Knark Project Trace your kubernetes runtime !! Kube-Knark is an open source tracer uses pcap & ebpf technology to perform runtime tracing on a de

Sep 19, 2022
GitOops is a tool to help attackers and defenders identify lateral movement and privilege escalation paths in GitHub organizations by abusing CI/CD pipelines and GitHub access controls.
GitOops is a tool to help attackers and defenders identify lateral movement and privilege escalation paths in GitHub organizations by abusing CI/CD pipelines and GitHub access controls.

GitOops is a tool to help attackers and defenders identify lateral movement and privilege escalation paths in GitHub organizations by abusing CI/CD pipelines and GitHub access controls.

Jan 2, 2023
tfa is a 2fa cli tool that aims to help you to generate 2fa code on CI/CD pipelines.

tfa tfa is 2fa cli tool that aim to help you to generate 2fa code on CI/CD pipelines. You can provide secret with stdin or flag. Install brew install

Nov 27, 2022
Dredger is a utility to help convert helm charts to Terraform modules using kubernetes provider.

dredger Dredger is a utility to help convert helm charts to Terraform modules using kubernetes provider. Dredger is made of dark magic and cannot full

Aug 25, 2022
Terraform provider to help with various AWS automation tasks (mostly all that stuff we cannot accomplish with the official AWS terraform provider)
Terraform provider to help with various AWS automation tasks (mostly all that stuff we cannot accomplish with the official AWS terraform provider)

terraform-provider-awsutils Terraform provider for performing various tasks that cannot be performed with the official AWS Terraform Provider from Has

Dec 8, 2022
Hackathon project with intent to help based on heuristics for aks cluster upgrades.
Hackathon project with intent to help based on heuristics for aks cluster upgrades.

AKS-Upgrade-Doctor AKS Upgrade Doctor is a client side, self-help diagnostic tool designed to identify and detect possible issues that cause upgrade o

Sep 20, 2022
Help my family picking secret santas without having a person beeing involved

secret-santa This is a small project I wrote to help my family picking secret santas without having a person beeing involved. This way noone is left o

Nov 6, 2021
Help developer to sync between local file and remote apollo portal web since portal web is so messy to use

apollo-synchronizer Help developer to sync between local file and remote apollo portal web since portal web is so messy to use Features download names

Oct 27, 2022
This project will help you to create Live img.shields.io Badges which will Count YouTube Stats (Subscriber, Views, Videos) without YouTube API
This project will help you to create Live img.shields.io Badges which will Count YouTube Stats (Subscriber, Views, Videos) without YouTube API

Free YouTube Stats Badge This project will help you to create Live img.shields.io Badges which will Count YouTube Stats (Subscriber, Views, Videos) wi

Oct 11, 2022