Recent

Author Topic: [CLOSED] InstanceSize  (Read 908 times)

julkas

  • Guest
[CLOSED] InstanceSize
« on: November 17, 2019, 03:29:19 pm »
InstanceSize method returns 16 on Linux and Mac. Windows - 8.
Class fields - Single, Pointer, Pointer, SizeInt, LongInt.
Who can explain?
Compiler options - -O3 -XX -CX.
Linux -
Code: Text  [Select][+][-]
  1. Free Pascal Compiler version 3.0.0+dfsg-2 [2016/01/28] for x86_64
  2. Copyright (c) 1993-2015 by Florian Klaempfl and others
  3. Target OS: Linux for x86-64
Mac -
Code: Text  [Select][+][-]
  1. Free Pascal Compiler version 3.0.4 [2018/10/02] for x86_64
  2. Copyright (c) 1993-2017 by Florian Klaempfl and others
  3. Target OS: Darwin for x86_64
Windows -
Code: Text  [Select][+][-]
  1. Free Pascal Compiler version 3.3.1-r20:43504 [2019/11/17] for i386
  2. Copyright (c) 1993-2019 by Florian Klaempfl and others
  3. Target OS: Win32 for i386
« Last Edit: November 17, 2019, 04:08:13 pm by julkas »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: InstanceSize
« Reply #1 on: November 17, 2019, 03:44:23 pm »
Even if we assume Linux is 64-bit and windows 32-bit, it doesn't add up, since even on 32-bit two pointers are already 8 bytes.

 Please show the declaration

julkas

  • Guest
Re: InstanceSize
« Reply #2 on: November 17, 2019, 03:53:27 pm »
Even if we assume Linux is 64-bit and windows 32-bit, it doesn't add up, since even on 32-bit two pointers are already 8 bytes.

 Please show the declaration
Code: Pascal  [Select][+][-]
  1. type
  2.   TIntTreap = TTreap<LongInt>;
  3. ...
  4.   WriteLn('TTreap<LongInt> instanceSize - ', TIntTreap.InstanceSize);
  5.  

Code: Pascal  [Select][+][-]
  1. type
  2.   TRandomHeap = class
  3.   public
  4.   type
  5.     PRandomHeapNode = ^TRandomHeapNode;
  6.     TRandomHeapNode = object
  7.       FPriority: Single;
  8.       FLeft: PRandomHeapNode;
  9.       FRight: PRandomHeapNode;
  10.       FSize: SizeInt;
  11.     end;

Code: Pascal  [Select][+][-]
  1. type
  2.   TTreap<T> = class(TRandomHeap)
  3.   public
  4.   type
  5.     PTreapNode = ^TreapNode;
  6.     TreapNode = object(TRandomHeapNode)
  7.       FKey: T;
  8.     end;

julkas

  • Guest
Re: [CLOSED] InstanceSize
« Reply #3 on: November 17, 2019, 04:09:56 pm »
Great question!

julkas

  • Guest
Re: InstanceSize
« Reply #4 on: November 17, 2019, 04:13:03 pm »
@marcov Thanks.

 

TinyPortal © 2005-2018