memory-layout Questions
2
Solved
The standard defines when two types are layout-compatible. But, I don't see anywhere in the standard what the consequences are when two types are layout-compatible. It seems that layout-compatible ...
Perennial asked 29/10, 2018 at 8:40
1
Solved
This is a big question, so I'm asking for a reference rather than a booklet-sized answer. I'm going through Stroustrup's Tour of C++, and it seems like the way objects are laid out is memory is fun...
Larissa asked 11/6, 2018 at 17:30
1
Solved
Here is a detailed description of VTT in the top-voted answer.But the answer does not explain why is there a top-offset in the VTT.
From my point of view,when we down_cast a base pointer to derive...
Habited asked 13/5, 2018 at 14:12
1
Solved
Recently,I learned that the .bss segment stores uninitialized data. However, when I try a small program as below and use size(1) command in terminal, the .bss segment didn't change, even if I add s...
Suspiration asked 9/12, 2017 at 10:30
2
Solved
This is after Java 6 memory model. In a 32bit JVM, the Shallow size of an object is
8 bytes (object header) + total of all instance variables + padding (optional)
If the first 2 terms don't add ...
Renewal asked 15/8, 2014 at 19:2
2
Solved
Warning: This is merely an exercise for those whose are passionate about breaking stuff to understand their mechanics.
I was exploring the limits of what I could accomplish in C# and I wrote a For...
Devonadevondra asked 8/8, 2017 at 10:50
3
Solved
I know that constant variables outside classes can be optimized directly into function calls by the compiler, but is it legal for the compiler to do the same for constant class variables?
If there...
Hijoung asked 31/7, 2017 at 14:5
2
Solved
I'm aware you can use MemoryLayout<T>.size to get the size of a type T.
For example: MemoryLayout<Int32>.size // 4
However, for class instances (objects), MemoryLayout<T>.size r...
Corpulent asked 28/10, 2016 at 19:37
2
Solved
I tried to measure the size of a struct and its fields (Playground):
use std::mem;
struct MyStruct {
foo: u8,
bar: char,
}
println!("MyStruct: {}", mem::size_of::<MyStruct>());
let obj ...
Rain asked 28/4, 2017 at 9:37
1
Solved
I have the following stack- and heap-allocated variables:
let var1 = 10;
let var2 = Box::new(10);
Printing these outputs the same value, 10:
println!("var1 ={} var2 ={}", var1, * var2);
When ...
Greenleaf asked 21/2, 2017 at 3:57
2
Solved
I have data laid out in memory in a Structure of Arrays (SoA) or Sturcture of Pointers (SoP) form, and have a way to access that data as though it were laid out in Array of Structure (AoS) form -- ...
Shivaree asked 12/2, 2017 at 4:43
2
Solved
Given this code:
#include <iostream>
struct A {
};
struct B {
};
struct C {
};
struct E : A {
int field;
};
struct F : A, B {
int field;
};
struct G : A, B, C {
int field;
};
in...
Hardening asked 31/10, 2016 at 22:48
1
Solved
#include <iostream>
#include <cstring>
// This struct is not guaranteed to occupy contiguous storage
// in the sense of the C++ Object model (§1.8.5):
struct separated {
int i;
sep...
Acculturation asked 30/9, 2016 at 12:42
4
Solved
In my first example I have two bitfields using int64_t. When I compile and get the size of the class I get 8.
class Test
{
int64_t first : 40;
int64_t second : 24;
};
int main()
{
std::cout &l...
Trainband asked 12/7, 2016 at 17:54
2
Solved
I'm trying to write some code in Fortran which requires the re-ordering of an n-dimensional array. I thought the reshape intrinsic combined with the order argument should allow this, however I'm ru...
Hydroxylamine asked 25/5, 2016 at 16:1
2
Solved
Swift and easy question: is std::bitset guaranteed to be contiguous in memory?
I know it abides by CopyConstructible and CopyAssignable concepts, but is it also a ContiguousContainer (or something...
Vostok asked 8/4, 2016 at 13:41
1
Solved
Is there an integral type that has the same size and alignment as a pointer?
There are std::intptr_t and std::uintptr_t, but I believe they don't have the same alignment as a pointer per se.
Lizalizabeth asked 27/11, 2015 at 18:28
2
Solved
Need to do a memory profiling of my C application ..
It should include footprint size and a RAM size ...
for example if my application is like below ..
#include <stdio.h>
int global = 10;...
Equatorial asked 9/11, 2015 at 13:6
2
Solved
For some compilers, if a class has virtual functions then its vptr can be accessed with the address of the first byte of its object. For instance,
class Base{
public:
virtual void f(){cout<<...
Agent asked 6/11, 2015 at 6:2
2
Yes, quite a few similar questions exist already (5037601, 19166698, 4855162, 14505995, 5052648, 13409508, 7745146, 7459630; sorry, not enough rep for more than 2 links), and yes, there are some ni...
Vachil asked 16/1, 2014 at 12:49
5
Solved
How can I prohibit the construction of an object? I mark = delete; all relevant special functions as follows:
struct A
{
A() = delete;
A(A const &) = delete;
A(A &&) = delete;
void...
Pasteboard asked 15/10, 2015 at 10:28
3
Solved
I have troubles understanding the exact meaning of a paragraph of C99 draft standard (N1256) about bit-fields (6.7.2.1:10):
6.7.2.1 Structure and union specifiers
[...]
Semantics
[...]
...
Budde asked 6/9, 2013 at 7:22
4
Solved
I was recently asked in an interview about object layout with virtual functions and multiple inheritance involved.
I explained it in context of how it is implemented without multiple inheritance in...
Stealing asked 24/8, 2009 at 8:13
3
Solved
I'm getting unexpected output from size command.
Afaik initialized global and static variables stored in data segment and uninitialized and initialized to 0 global/static variables stored in bss ...
Sundried asked 26/3, 2015 at 21:29
2
Solved
So I've been reading these two articles and this answer
Cannot convert []string to []interface {} says that the memory layout needs to be changed.
http://jordanorelli.com/post/32665860244/how-t...
Dottiedottle asked 13/3, 2015 at 6:36
© 2022 - 2024 — McMap. All rights reserved.