Skip to content

Instantly share code, notes, and snippets.

@avitale
avitale / totalsize.test.jl
Last active August 29, 2015 14:04
Test for totalsizeof
using Base.Test
@test totalsizeof(4) == sizeof(4)
@test totalsizeof(4.0) == sizeof(4.0)
@test totalsizeof("Test") == sizeof("Test")
@test totalsizeof('\t') == sizeof('\t')
@test totalsizeof(Nothing) == sizeof(Nothing)
# Array of Integer
a = [1,2,3]
@avitale
avitale / totalsize.jl
Last active February 16, 2020 12:51
Total size of Julia objects
module Totalsizeof
importall Base
export totalsizeof
# Helper: Pointer cache is used to break circular references in objects and avoid double countings
is_seen!(x, ptr_cache) = in(pointer_from_objref(x), ptr_cache) || (push!(ptr_cache, pointer_from_objref(x)); false)
# Helper: Catch types without size method
sizeof_catch(x) = try sizeof(x) catch 0 end
<!DOCTYPE html>
<html>
<head>
<title>Heatmap</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.25.0"></script>
<style type="text/css">
svg {
shape-rendering: crispEdges;
}