Monday, May 31, 2010

How to use LFH

작년에 메모리 할당자 성능체크 하느라 만들었던 코드인데,
http://eeodl.blogspot.com/2009/04/benchmark-of-memory-allocators.html

I wrote this code last year to check a performance of a couple of memory allocators,

걍 회사 하드에 있던 거 백업용으로 여기다가도 올려놓음.
It just is on office computer, so I post it to remember.

리마인드 시켜준 경만옹께 감사를.
Thanks NomoreID for reminding this.

주의 : 이 코드는 예외 처리가 매우 간단하게 되어 있으므로 가져다쓰실 분은 잘 고쳐서 쓰시기 바랍니다.
Note : You'd better enhance an exception handling if you take this code, because its exception handling is too simple.

#include 

class ActorHeap : public ActorInterface
{
public:
 ActorHeap() : initial_size_(0), use_lfh_(0), heap_(0) {;}
 ActorHeap(size_t initial_size, bool use_lfh) : initial_size_(initial_size), use_lfh_(use_lfh), heap_(0) {;}

 ~ActorHeap()
 {
  if (IsValid() == false)
   return;

  HeapDestroy(heap_);
 }

 void Init()
 {
  heap_ = HeapCreate(HEAP_CREATE_ENABLE_EXECUTE, initial_size_, 0);
  if (!heap_)
  {
   printf("HeapCreate failed. (%d)\n", GetLastError());
   return;
  }

  if (use_lfh_)
  {
   ULONG HeapFragValue = 2; // enable low fragmentation heap
   if (!HeapSetInformation(heap_, HeapCompatibilityInformation, &HeapFragValue, sizeof(HeapFragValue)))
   {
    printf("LFG initialization failed. (%d)\n", GetLastError());
   }
  }
 }

 void* Alloc(size_t size)
 {
  if (IsValid() == false)
   return NULL;

  void* block = (void*)HeapAlloc(heap_, HEAP_ZERO_MEMORY, size);
  return block;
 }

 void Free(void* block)
 {
  if (IsValid() == false)
   return;

  BOOL result = HeapFree(heap_, 0, block);
  if (!result)
  {
   printf("HeapFree failed.\n");
  }
 }

 bool IsValid() { return heap_ != NULL; }

private:
 size_t initial_size_;
 bool use_lfh_;

 HANDLE heap_;
};

The size of member function pointers

성경형이 알려준 거 날로 먹기.

혹시라도 당하게 되면 당황하지 말고 잘 고치도록 하자. ㅎㅎ

http://minjang.egloos.com/1458391

http://blog.naver.com/drvoss/20041594354

한줄로 정리하면,

상속 받은 클래스의 멤버 함수 포인터 크기는 다르게 할당될 수 있다.

Wednesday, May 26, 2010

One Republic - All the right moves



최근 한달동안 나의 귀에 촥촥 감겼던 노래.
I've been listening to this song for last month. very good.

Wednesday, May 19, 2010

A big Rilakkuma


한국에 있는, 이제 곧 30이 되지만 아직도 너무 어린, 매날 지는 LG 를 응원하는,
회사 동료 때문에 매일 스트레스 받는, 민아 어린이가 보면 좋아할 그 녀석.

리락쿠마? 리라쿠마? 랄라쿠마?
색소폰 학원 건물에 있길래 집에 가는 길에 함 찍어봤음.

Hock Lam Beef

얼마전 트위터에다가 글 썼던 그곳.
I mentioned it at Twitter a couple of days ago.

싱가폴에서 엄청 유명하다는 소고기 누들 집.
I heard that it's a very famous beef noodle restaurant.

무려 월요일 부터 수요일까지는 영업을 하지 않는 배가 부를대로 부른 그 집.
They don't open between Monday and Wednesday. Huh? Too much proud!!!




영훈이나 오준이는 겁나게 싫어할 듯. 샹차이가 들어있거덩. ㅋ

맛은 그저 그랬음. 기대 많이 했었는데... 아~~ 설렁탕이 먹고 싶다~

The day I just moved in a new house.


A lot of boxes and items.



A small building. You can see my home in that picture. :)

By the way, I moved in this house at 5th May 2010.

Sunday, May 16, 2010

The Dance - Dave Koz (ft. BeBe Winans)



My favorite song in Dave Koz's all albums.
BeBe Winans is popular by R&B and CC songs. What an amazing voice!


This version is featured by Park Hyo Shin (a Korean singer).
It's also nice. Don't try to compare with BeBe Winans. BeBe is one of the best R&B singer in the world. :-)



There is no live version of this song voiced by BeBe Winans.
(There is only one clip. But, the sound is too noisy.)

Thursday, May 13, 2010

Microsoft joins cloud software battle

An interesting article.

http://edition.cnn.com/2010/TECH/05/13/microsoft.cloud.computing/index.html?eref=edition_business&utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+rss/edition_business+(RSS:+Business)

By the way,

Now, CNN is fully integrated to Facebook external API.
So, I can recommend this article on CNN website to Facebook my note. What a good stuff!!

But, there are still small bugs.
It will be resolved soon. I believe in Facebook. :)

Wednesday, May 12, 2010

Syntax Highlighting test

http://heisencoder.net/2009/01/adding-syntax-highlighting-to-blogger.html

// staticInherited.cpp : Defines the entry point for the console application.
//

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

class base
{
public:
 base() : m_BaseValue(1) {;}

 static base& GetInstance();
 
 void setBase(int value) { m_BaseValue = value; }
 int getBase() { return m_BaseValue; }

 void setBaseStatic(int value) { m_BaseStatic = value; }
 int getBaseStatic() { return m_BaseStatic; }

private:
 int m_BaseValue;
 static int m_BaseStatic;
};

class child : public base
{
public:
 child() : m_ChildValue(2) {;}

 static child& GetInstance();
 
 void setChild(int value) { m_ChildValue = value; }
 int getChild() { return m_ChildValue; }

 void setChildStatic(int value) { m_ChildStatic = value; }
 int getChildStatic() { return m_ChildStatic; }

private:
 int m_ChildValue;
 static int m_ChildStatic;
};

int _tmain(int argc, _TCHAR* argv[])
{
 base b;
 child c;

 c.setBaseStatic(5);

 base::GetInstance().setBaseStatic(20);
 child::GetInstance().setBaseStatic(1);
 
 c.setChildStatic(11);
 child::GetInstance().setChildStatic(22);

 base bb;
 child cc;

 cc.setChildStatic(55);
 cc.setChild(100);
 bb.setBase(30);
 bb.setBaseStatic(200);

 child::GetInstance().setChild(40);
 child::GetInstance().setBase(77);

 base::GetInstance().setBase(44);
 base::GetInstance().setBaseStatic(888);

 return 0;
}

int base::m_BaseStatic = 0;
base& base::GetInstance()
{
 static base b;
 return b;
}

int child::m_ChildStatic = 0;
child& child::GetInstance()
{
 static child c;
 return c;
}

참고로 이 코드는 아무짝에 쓸모없는 코드임을 밝힙니다. :-)

Tuesday, May 11, 2010

A simple example of boost function & bind.

I had a talk with David about boost bind today.
I've used boost::bind by referencing to some articles and blogs so far like MSDN.

When David asked me how to use it, I can't show a simple example to him.
Even boost web site has a bit complex example.
So, I record a very very simple example how to use it.

sample x;
boost::function< int (int,int)  > f;
f = boost::bind(&sample::get, x, _1, _2);
f(1,2);

That's it.

Macros in VS, gcc

http://wiki.fracktal.kr/doku.php?do=export_xhtml&id=개발:프로그래밍_언어:c:매크로

Good.

Sunday, May 9, 2010

A running at last night


I ran (jogging) last night.
Before running, I check a route on google maps.
I was thinking that it's a normal course.

However, it was a long route unfortunately.
You can see the entire distance - 7.5km - on the above picture.
In addition, I ran over 1.3 km at Punggol Park which locates around destination C.
(By the way, the Punggol Park is very nice. I want to go there more.)
So, the total distance is approximately 8.8km.

I think I can't run this route on weekdays.
Because I usually spend most of my power at the office.
I need to find the other route for weekdays.
If I run this route at weekdays, I may be late for work. :-)

Friday, May 7, 2010

SignalObjectAndWait

http://msdn.microsoft.com/en-us/library/ms686293(VS.85).aspx

So far, I haven't used this API because it only handles kernel objects.
In general, most programmers prefer using a user-mode lock object instead of kernel objects.
(e.g. critical section, slim rw lock)

By the way, in case of using multiple kernel objects, this API is very useful for performance.

Thursday, May 6, 2010

Moving is done.

모든 이사와 관련된 작업을 마쳤다.
Moving is completed.

지금은 짐정리 중인데 적어도 몇일은 걸릴 듯 하다.
It may take a couple of days to unpack and rearrange all things.

이런 저런 것들을 나열해 보면,
Many issues came to me.

- 지금 인터넷이 안된다. 아 고객서비스 느려터진 Singtel. 왕 짜증.
- Now I can't use Internet at home. Bad Singtel!!! Too bad custom service.

- 집 크기가 지난집보다 2/5 정도로 줄어들었다. 혼자살기엔 적당하지만, 사람 많이 부르긴 불가능.
- The size of the entire house is smaller than ex-house about 40%. It's enough for me, but I can't invite many friends.

- 수납공간이 턱없이 부족하다. IKEA 다시 가줘야 할 듯.
- Not enough drawers. I need to go to IKEA again.

- Gym 없고, 옥상에 수영장이 있긴 있는데 길이가 10m 정도 되나. -_-
- No Gym. There is a swimming pool on roof but it's too small. (10m width?)

- 덤벨 사러가기 귀찮다.
- It's too trouble some to buy dumbbell.

- 지하철과는 걸어서 8분 정도 거리. 이건 좋음.
- It takes 8 minutes from home to MRT station by walk. That's good.

- 출근시간이 2.5배로 늘어났다. (15분 -> 40분)
- The time duration of going office from home is getting longer. (about 40 minutes)

- 창문에 방음설계가 잘 되어 있어서 색소폰 마음껏 부를 수 있겠다 생각했는데, 다 이유가 있었다.
- Windows have a soundproof system. So I thought I could play saxophone anytime. But there is a special reason.

- 저녁 7시~8시 사이에 비행기가 엄청 많이 뜬다. 아 이놈의 비행기 소리.
- I hear sounds of airplanes a lot of times between 7 pm to 8 pm. !!!!!!

- 물론 창문닫으면 전혀 안들리긴 한다. 좋게 생각하면 저 시간대에 색소폰을 연습하면 되겠군.
- By the way, I can't hear the sound if I close all windows. Well. A good thing is that I can play saxophone at that time.

- 세탁기가 LG Tromm. 꽤 좋은 듯?
- A washing machine is Tromm by LG. It's good.

- 냉장고가 너무 작아서 불만.
- However, a fridge is too small.

- 침대도 좀 짧다. 원래 이거 여성용 집인가?
- In addition, a bed is too short. Is it for girls?

- 신발장이 없다. 이것도 사야할 듯.
- No shoe rack. I need to buy a new one.

- 거실 인테리어에 골머리 중.
- I have a trouble how to make an interior for living room.

정리가 다 되면 사진도 올리겠음~
I will upload pictures when I finish to rearrange all things.

Monday, May 3, 2010

Hoon's couple at Jumbo


영훈이와 누님. 이날 비가 주구장창 오더니 4시부터 맑아졌음.

여태껏 이곳을 6번 왔는데 민아왔을 때만 비가 왔....

Terry in Singapore Flyer


잉여킹 in 싱가폴 플라이어. 인증샷.

Mina in Sentosa


절대로 고개를 돌리지 말찌니라.

Paranormal Activity


친구들이 강추하길래 기대감을 가지고 봤음!
I expected this movie because a couple of friends said it's very scary.

그런데, 전혀 무섭지가 않아서 꽤나 실망 ㅠㅠ
However, It's not scary at all. 

이미 아시아쪽 공포영화로 단련된 나에게 이 영화는 역부족이었음.
It's not enough for me to get scary - I've been trained from Asia's horror movie.

사실 이런 심령 공포영화는 아시아 계열 영화가 대박아닌가.
I think the movie which shows some psychology is usually very scary in Asia's one.

우리나라의 수많은 귀신이야기도 그렇고,
Lots of Korean movies are scary.

전설이 되어버린 일본의 링과 주온.
So are Ring and Ju-on in Japan,

그리고 태국 영화들도 무섭고.
And some Thailand's movie is also scary.

아마 미쿡에서 호평을 받은 이유는, 그들에게는 매우 신선하였기 때문에 그런듯.
I think why this movie has got a good score in U.S, because it's a new style for them.

그 전까지의 양키 스타일 공포영화는,
So far scary movies in U.S. are like

- 어떤 싸이코의 연쇄살인
- Some crazy guys sequential murder.

- 흡협귀 류의 공격
- Attack from Dracula or Vampire.

- 종교와 관련된 악령들. (무적의 성수와 십자가)
- Evils related to religion. Especially Christian.

이런 류의 영화만 나왔었지만, 파라노멀 액티비티는 과거의 예들과는 상당히 다름.
Paranormal Activity is pretty much different from the usual horror movie in U.S.

아시아쪽 공포영화를 벤치마킹 한 느낌.
It gives me feeling that it has got many references from Asia's horror movies.

실망을 하긴 했지만 그래도 '다른 결말' 도 찾아보고 나름 즐겁게 봤음. (유투브에 있음.)
By the way, I enjoyed this movie so that I watched the clip of the other ending even though it's not very scary.
(You can find the clip on Youtube.)

근데 영화가 너무 헛점이 많다 ㅎㅎ
One thing, there are lots of faults in this movie. LoL.



헛점 중 하나. 왜 자꾸 일이 터지는 데 계속 그 집에서 쳐 자는거냐고.
헛점 하나 더. 왜 자꾸 일이 터지는 데 여자가 계속 문 옆에서 쳐 자는 거냐고.
내 참 보는 내내 답답해서.

Sunday, May 2, 2010

Now I'm

요새 근황.
So, these days,

트위터에다가 꾸준히 글을 쓰다보니 정작 이곳에는 소흘.
I didn't spend as many time as before because of twitter.

정들었던 리버플레이스(이전 집)와의 계약이 끝나서 이사를 했음.
I moved out River Place yesterday.

근데 이사 날짜가 맞지를 않는 바람에 5일(수)에 다시 이사를 함.
Unfortunately, the moving date is out of sync so I'm moving again.

지금은 재호형이 미겔형으로부터 임대한 Compass 콘도에서 캠프 중.
Now, I'm staying at Jaeho's house which Miguel rents to Jaeho.

3일 후에 나가니 이사짐은 그대로 쌓아놓기만 했음.
All luggages are stacked up because I'm moving in 3 days.

아 이사는 참으로 번거롭다.
It's too much troublesome to move a house.


글고 회사에 크고 작은 일들이 계속 생기고 있어서 은근히 스트레스 받는 중.
These days I've got more stress because of work and some more.

이사 준비하랴 이래저래 딴 거 좀 준비하랴 운동을 거의 못하고 있음.
In addition, I couldn't exercise as preparation of moving.

색소폰 학원도 3주 연속 못나가고 있음... 아 1g 정도 생긴 실력이 초기화 되는 듯한 느낌.
One more bad thing is that I couldn't go a saxophone lesson for 3 weeks.
I'm afraid that I'm going to forget how to play my sax.