c++ low-latency connectivity IV (nQuant) #2

This IV is heavy on low-level details of C/C++.
Q3a: Memory alignment – what if on the stack I declare 2 char variables?
Q3b: what if I put those 2 char variables in a struct?
Q3c: I have two 64-bit ints, one misalinged. When I use them what problems will I have?
Q1: If inside a member function I call “delete this”, what happens?
%%A: what if this “this” points to an object embedded as a field of an umbrella object? The deallocation would happen, but the destruction of the umbrella object may again deallocate it? This is confirmed in the FAQ (http://www.parashift.com/c++-faq-lite/delete-this.html)
%%A: how do we know the host obj is on heap, stack or global area
Q1b: To achieve heap-only, my class has private ctors and private op= and a static factory method. Will it work?
%%A: according to moreEffC++ P146, I would say yes, with certain caveats.
Q2: What’s reinterpret_cast vs dynamic_cast vs static_cast?
Q2b: What other casts are there?
Q: Placement new – can I use the regular “delete”?
%%A: probably no. Need to call the dtor manually? See P42 moreEffC++
Q: How does tcp handshake work?
A: http://en.wikipedia.org/wiki/Transmission_Control_Protocol#Connection_establishment
Q: Some tcp parameter to speed it up?
A: larger TCP window size
Q: tcp client to specify a non-random port? See post on bind()
Q: If a c++ app runs fine in debug build (compiler optimizations removed), but crashes in release mode, what guesses/clues do you have?
%%A: conditional compilation, like in my c# project
%%A: the compiler optimization leads to unusual execution speed between 2 threads, and cooks up a rare corner case
%%A: I have seen assertions turned on in debug build (a debug STL can also be used), so we know one data file F1 is unusable, and another data file F2 is usable. In release build, someone else tries F1 and it crashes somewhere else.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s