Saturday, October 1, 2016

VMMap and RamMap

VMMap:
(1) VM Types: image,mapped-file, Heap, stack(for threads)
(2) VM alloc: Committed, Reserved, Private, Shareable 
(3) Task manager does not show type
(4) Working set = RAM
(5) Graph1 -- coloring Private data in private bytes along non-data
    Graph 2 -- Working set with portion colored as private data
          shows how much private data actually in WS.


RamMap
(6) Page List: Working Set =>Modified Page List (still in RAM)
               => StandBy Page List (Disk) by ModPage Writter
(7) Process Explorer/System Info shows all page List: Zero
    StandBy, Modify, Free.
(8) Did global or heap var in your app pass through the list?


(9) File Summary: For each process, Page List view
(10) Priority summary: How much re-pupose on Priority 7=> Ram Pressure
(11) Physical Pages: Mapped-File full path

Thursday, September 29, 2016

C++ 17 on Compiler Explorer

http://gcc.godbolt.org/
Clang support C++17 more feature than gcc 6.9


//Clang 3.9.0 compiler option -std=c++11

#include <tuple>

using namespace std;

int test1()
{
  return 99;
}

std::tuple<int,int> test()
{
 return make_tuple<int>(1,2); 
}

int main()
{
  // const auto [s1,s2]=test(); // structured binding not working
  if( const auto i=test1();i==1) { //if-init works
  }
    return 0;
}

Sunday, September 25, 2016

Pool vs New Thread schedule for Rx and a C++ optimzed book





https://s3-ap-southeast-1.amazonaws.com/mylekha-ebook/IT+%26+Programming/c_c%2B%2B_c%23/Optimized-C%2B%2B.pdf





NewThread is EventLoopThread inside each nested call and new on each non-nested.

when subscription on background blocks more than 50ms use NewThread, otherwies use Pool Thread

macro for property definition


#define VIRTUAL_VAL_RO_PROPERTY(Access, PropertyType,PropertyName,Field) \
    property PropertyType PropertyName        \
    {                        \
    virtual PropertyType __clrcall get()            \
    {                    \
    return Field;            \
    }                    \
    } \
private:                    \
    PropertyType Field;                \
    \
Access:

volatile, reinterpre_case, constexpr, lambda and destructuring in C++14 and 17


#include "stdafx.h"
#include <iostream>

using namespace std;

namespace {
 volatile uint8_t &memory(const uint16_t loc)
 {
  return *reinterpret_cast<uint8_t*>(loc);
 }

 struct VIC_II
 {
  static constexpr uint16_t COLOR = 0xd020;
  volatile uint8_t &border()
  {
   return memory(COLOR);
  }
  volatile uint8_t& display(const uint8_t col, const uint8_t row)
  {
   return memory(1024 + col + row * 40);
  }


  auto test()
  {
   return std::make_tuple<int,int,int>(1, 2, 3);
  }
 };
}
int main()
{
 const auto le = [](uint8_t i) {cout << i << endl; };

 le(3);
 VIC_II vic;
 vic.border() = 1;
 vic.border() = 2;
 memory(1024) = 'a';
 vic.display(1, 2) = 'b';
 
// destructuring inside if does not work in VS 2015
// i.e. structured binding + if initializer
 if ( auto [s1, s2, s3] = vic.test();s1==1)
 {

 }
    return 0;
}

volatile, reinterpre_case, constexpr, lambda and destructuring in C++14 and 17


#include "stdafx.h"
#include 

using namespace std;

namespace {
 volatile uint8_t &memory(const uint16_t loc)
 {
  return *reinterpret_cast(loc);
 }

 struct VIC_II
 {
  static constexpr uint16_t COLOR = 0xd020;
  volatile uint8_t &border()
  {
   return memory(COLOR);
  }
  volatile uint8_t& display(const uint8_t col, const uint8_t row)
  {
   return memory(1024 + col + row * 40);
  }


  auto test()
  {
   return std::make_tuple(1, 2, 3);
  }
 };
}
int main()
{
 const auto le = [](uint8_t i) {cout << i << endl; };

 le(3);
 VIC_II vic;
 vic.border() = 1;
 vic.border() = 2;
 memory(1024) = 'a';
 vic.display(1, 2) = 'b';
 
// destructuring inside if does not work in VS 2015
 if ( auto [s1, s2, s3] = vic.test();s1==1)
 {

 }
    return 0;
}

Monday, July 4, 2016

PE 64 vs 32 bit, std::data() vs c_str, version replace in csproj, CLang


PE headers in DLL telling x86 vs. x64:
x86:
PE  L
x64:
PE  d†

Better use std string data():
std string c_str() is null terminated char only convertion, must use data() if source is encoded from binary data.

Clang and MinGw:
VS 2015 update 3 bring down Clang in a checkbox "Clang with MS codeGen", using LLVM for cross platform, Low Level VM
clang, clang++ are under "program files .. visual studio vs" directory and some androi directory after update 3
MinGW is Windows Implementation of gcc


csproj and Nuget packages.config version changes
find . -type f -print | xargs grep "1.6.0.1"
$ sed -i 's/1.6.0.1/1.6.0.2/g' project1.csproj
$ find /proj/code -type f -exec sed -i 's/1.6.0.1/1.6.0.2/g' {} \;

#!/bin/bash
      for fl in *.php; do
      mv $fl $fl.old
      sed 's/FINDSTRING/REPLACESTRING/g' $fl.old > $fl
      rm -f $fl.old
      done