2015. 12. 2. 10:15

[펌] http://withwani.tistory.com/150


포스트 내용의 참고자료 출처 : 소설같은자바 Third Edition

   

JAVA에서 기본적인 자료 구조를 제공하기 위한 환경을 JAVA Collection Framework라고 한다.

다음은 JAVA Collection Framework의 상속 기본 구조이다.

  

   

  1. Collection

    Collection 인터페이스를 상속받아 List와 Set 인터페이스가 된다. List는 순서가 있는 Collection, 그리고 List는 Data 중복을 허락한다. 하지만 Set은 순서의 의미가 없으며 Data를 중복해서 포함할 수 없다.

  • List 인터페이스의 특징
    • 순서가 있는 Collection.(이 순서는 삽입된 순서를 의미한다.)
    • Data를 중복해서 포함할 수 있다.
    • Stack의 특징
      • Data의 삽입과 추출이 후입선출(Last-In First-Out) 구조로 되어 있다.
      • push() method : Data 삽입할 때 사용
      • pop() method : Data 추출할 때 사용
      • peek() method : 추출할 Data를 삭제하지 않고 Data만을 가져 올 때 사용
      • search() method : Stack으로부터 Data를 검색할 때 사용
    • Vector의 특징
      • 자동으로 동기화를 보장해준다.
      • ArrayList에 동기화가 보장되도록 최적화한 클래스이다.
      • JAVA 5.0 이 후로는 AutoBoxing/AutoUnBoxing을 지원한다.
        • AutoBoxing이란? 기본 Data 타입을 Wrapper 클래스형의 객체로 자동으로 변환해주는 기능. AutoUnBoxing은 AutoBoxing의 반대 개념
        • JAVA 1.4까지

Vector v = new Vector();
v.addElement(new Integer(100));

  • JAVA 5.0이후

Vector v = new Vector();
v.addElement(100); // AutoBoxing 발생, 자동으로 Wrapper class인 Integer로 변경

  • addElement() method : Data를 삽입할 때 사용
  • elementAt() method : Data를 추출할 때 사용, Index에 해당하는 객체를 얻어냄
  • size() method : Vector 내에 존재하는 객체의 수를 얻어낼 대 사용
  • insertElementAt() method : Vector 내에 중간 삽입할 때 사용
  • setElementAt() method : Vector 내에 존재하는 Data를 수정할 때 사용
  • indexOf() method : Vector 내에 Data를 검색할 때 사용, Index를 반환
  • contains() method : Data의 존재 유무를 알기 위해 사용.
  • ArrayList의 특징
    • 동기화를 보장해주지 않는다.
    • 배열에 동적 메모리 증가 기능을 구현한 클래스이다.
    • 동기화 지원 방법 : List list = Collections.synchronizeList(new ArrayList(…));
    • add() method : Data 삽입할 때 사용
    • get(0 method : Data 추출할 때 사용
    • toArray() method : ArrayList로부터 배열 얻어낼 때 사용
    • contains() method : Data의 존재 유무를 알기 위해 사용
    • size() method : ArrayList의 요소 개수를 얻어낼 때 사용
  • Set 인터페이스의 특징
    • 집합적인 개념의 Collection
    • 순서의 의미가 없다.
    • Data를 중복해서 포함할 수 없다.
    • HashSet의 특징
      • add() method : Data 삽입할 때 사용
      • next() method : Data 추출할 때 사용
        • HashSet의 Data 추출은 Iterator을 이용하면 된다. Iterator는 Collection내의 모든 Data에 접근할 수 있는 특징이 있다. 그리고 Data의 마지막에 상관하지 않고 검색하기 위한 인터페이스이다. Set의 Iterator() method로 Iterator를 얻어 낼 수 있으며, Iterator의 hasNext() method를 이용해서 Data 끝을 만날 때까지 next() method를 호출해서 Data를 추출할 수 있다.

Iterator<String iter = set.iterator();
while(iter.hasNext()) {
String temp = iter.next();

System.out.print(temp + ", ");
}

  • remove() method : Data를 삭제할 때 사용
  • contains() method : Data의 포함여부를 알기 위해 사용
  • size() method : HashSet의 요소 개수를 얻어낼 때 사용

       

  1. Map

    List와 Set이 순서나 집합적인 개념의 인터페이스라면 Map은 검색의 개념이 가미된 인터페이스이다. Map 인터페이스는 데이터를 삽입할 때 Key와 Value의 형태로 삽입되며, Key를 이용해서 Value를 얻을 수 있다.

  • Hashtable, HashMap의 공통점
    • 내부적으로 모두 Hash 기법을 이용한다.
    • Map 인터페이스를 구현하고 있다.
    • Key와 Value를 이용해서 Data를 관리한다.
  • Hashtable, HashMap의 차이점
    • Hashtable은 동기화가 보장된다.
    • HashMap은 동기화가 보장되지 않는다.
    • HashMap의 동기화 지원 방법 : Map m = Collections.synchronizedMap(New HashMap(…));
  • Hashtable, HashMap과 HashSet과의 관계
    • Hashtable과 HashMap은 둘 다 Map 인터페이스를 구현하고 있다.
    • HashSet은 내부적으로 Hash기법을 사용하지만 Set인터페이스를 구현하고 있다.
  • HashMap
    • 객체 생성 : Map<String, Integer> map = new HashMap<String, Integer>();
    • put() method : Data 삽입할 때 사용
    • get() method : Data를 추출할 때 사용, argument값은 Key를 사용
  • Hashtable
    • 객체 생성 : Hashtable<String, Object> h = new Hashtable<String, Object>();
    • put() method : Data 삽입할 때 사용
    • get() method : Data를 추출할 때 사용, argument값은 Key를 사용

   

  1. Sorted

    Set과 Map 인터페이스를 상속받아 정렬 기능이 추가된 SortedSet과 SortedMap 인터페이스가 된다. 그리고 이들은 각각 TreeSet 클래스와 TreeMap 클래스로 구성된다. TreeSet과 TreeMap은 Set과 Map의 기능을 가지고 있으면서 정렬 기능이 가미되었다는 것이 특징이다.

  • Sorted를 지원하지 않는 클래스
    • HashSet, HashMap
  • Sorted를 지원하는 클래스
    • TreeSet, TreeMap
  • TreeMap
    • Key와 Value로 Data를 관리
    • Key를 기준으로 오름차순으로 정렬된다.
    • Map 인터페이스를 상속한 SortedMap 인터페이스를 구현한 클래스
  • TreeSet
    • Set 인터페이스를 상속한 SortedSet 인터페이스를 구현한 클래스
    • 데이터들이 자동으로 오름차순으로 정렬된다.
  • Comparator
    • TreeSet과 TreeMap은 사용자가 직접 정렬의 방식을 지정할 수 있다.
    • TreeSet과 TreeMap은 정렬을 위한 Comparator 인터페이스를 구현하면 된다.
    • TreeSet에 Data를 집어 넣으면 기본적으로 오름차순(Ascending) 정렬이 되지만 그것도 문자열이나 기본 데이터 타입과 같은 단순한 것에만 해당된다. 이에 사용자가 직접 비교법을 넣어주기 위해 사용하는 것이 Comparator 인터페이스이다.
    • Comparator의 구현 방법 : Comparator 내부에 compare() method를 구현하면 된다.

class Mycomparator<T> implements Comparator<T> {
public int compare(T o1, T o2) {
// 비교방법 구현
}

  • Comparator가 추가된 TreeSet의 생성

TreeSet<Score> tset = new TreeSet<Score>(new MyComparator<Score>());

  • Comparator가 추가된 TreeMap의 생성

TreeMap<Score, String> tset = new TreeMap<Score, String>(new MyComparator<Score>());

  • 일반적인 정렬기능의 사용
    • HashSet이나 HashMap을 정렬 기능이 지원되는 TreeSet이나 TreeMap으로 변환해서 사용
    • HashSet을 이용한 TreeSet 생성

Set<String> set = new HashSet<String>();
...
TreeSet<String> ts = new TreeSet<String>();
ts.addAll(set);

  • HashMap을 이용한 TreeMap 생성

Map<String, Integer> map = new HashMap<String, Integer>();
...
Map<String, Integer> sortedMap = new TreeMap<String, Integer>();
sortedMap.putAll(map);


Posted by 까망후니
2015. 12. 2. 10:10

[펌] http://k.daum.net/qna/openknowledge/view.html?qid=40E4I


HashMap에 entrySet 메소드를 호출하면 키가 들어있는 Set이 넘어 옵니다.


Set에서 iterator를 뽑아내면 whlie 문으로 루프를 돌려서 키를 하나씩 가져올 수 있습니다.

아래 코드는 가져온 키를 기준으로 값을 가져와서 출력한 샘플 입니다.

public static void main(String[] args) {

    Map<String, String> map = new HashMap<String, String>();
    map.put("A", "aaa");
    map.put("B", "bbb");
    map.put("C", "ccc");
    map.put("D", "ddd");
    map.put("E", "eee");
    map.put("F", "fff");
    
    Set<Entry<String,String>> entrySet = map.entrySet();
    Iterator<Entry<String, String>> iterator = entrySet.iterator();
    while (iterator.hasNext()) {
        Map.Entry entry = (Map.Entry) iterator.next();
        System.out.println(entry.getKey() + "=" + entry.getValue());
    }
}

출력 결과는 아래와 같습니다.

D=ddd
E=eee
F=fff
A=aaa
B=bbb
C=ccc

Posted by 까망후니
2015. 12. 2. 10:08

[펌] http://whatiscomingtomyhead.wordpress.com/2012/01/02/get-rid-of-unmappable-character-for-encoding-cp1252-once-and-for-all/


내컴퓨터 - 고급시스템 설정 - 고급 - 환경변수


시스템 변수 - 새로 만들기

 - 변수이름 : JAVA_TOOL_OPTIONS

 - 변수 값 : -Dfile.encording=UTF-8

'언어 > JAVA' 카테고리의 다른 글

JavaCollection(List, Set) 과 Map 설명  (0) 2015.12.02
HashMap 의 Key, value 값 가져오기  (0) 2015.12.02
JAVA 설치  (1) 2015.12.02
Posted by 까망후니
2015. 12. 2. 09:56

간만에 PC를 포맷하면서 다시 처음부터 JAVA를 설치하였다.


혹시나 또 까먹을까봐.. 적어놔야지..ㅎㅎ


http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html


가서 Windows x64의 JDK를 다운 받고 설치한다.


여기까지는 쉽고..


내컴퓨터 속성 - 고급시스템설정 - 고급 탭 - 환경변수 클릭


시스템변수 - 새로만들기 클릭


변수이름 : JAVA_HOME

변수 값 :  C:\Program Files\Java\jdk1.8.0_31  ===>위에서 설치된 JAVA 경로입니다.


그 다음


시스템 변수 - Path 더블클릭(또는 편집)

변수 값 : ;%JAVA_HOME%;%JAVA_HOME%\bin;  ==> 추가


이러고


cmd 창에서 javac 입력해서 제대로 주루룩~ 나오면 성공~



아 참고로 JAVA_HOME 이라고 이름 짓는 이유는 톰캣에서 찾는 기본 경로가 JAVA_HOME 이기 

때문이라고 알고 있는데...ㅎㅎ..

맞는지는..

Posted by 까망후니
2015. 12. 2. 09:43

이 방법은 Microsoft SQL Server Management Studio로 Password를 변경하는 방법이다.


Admin 계정으로 로그인 후에 새쿼리 창을 열고 아래의 방법으로 입력하고 수정하려는 걔정과 Password를 입력하고 실행하면 된다.


sp_password null, '변경할 패스워드 입력', '계정정보 입력';


ex) sp_password null, 'Password', 'sa';

'DB > MSSQL' 카테고리의 다른 글

Try Catch 예제  (0) 2017.09.05
오전오후 -> datetime 변환  (0) 2017.03.28
index 방법  (0) 2017.02.23
MSSQL express to standard upgrade  (0) 2016.11.18
[MSSQL] MSSQL MANAGEMENT에서 테이블 수정 안되는 오류  (0) 2015.12.14
Posted by 까망후니
2015. 12. 2. 09:42

vi /etc/ssh/sshd_config  입력해서 나오는 화면중에 

.....

PermitRootLogin yes / no (허용하면 Yes, 불허하면 No)

.....

설정하고 저장 후 빠져나오고

아래의 명령 실행하면 끝!


Centos 6 이하 : service sshd restart

Centos 7 : systemctl restart sshd.service

'OS > 리눅스' 카테고리의 다른 글

chmod, chown 파일권한과 소유권 변경  (0) 2018.06.21
[OVM] Oracle Virtual Machine 관련  (0) 2018.05.18
[CentOS 7] 네트워크 설정 방법  (0) 2018.05.08
[CentOS] 설치 관련 정보  (0) 2016.06.27
[리눅스] CentOS 설치 방법  (0) 2015.12.01
Posted by 까망후니
2015. 12. 2. 08:50

저도 소개받은 라이브러리인데, 아직 개발에 직접 써보진 않았지만 문서만 읽음으로도

오우~ 라는 소리가 날 정도로 괜찮아 보이는 라이브러리를 소개합니다.

일단 "무료"(MIT license)라는 사실이 기가 막히네요..ㅎㅎ


URL : http://handsontable.com/


자바스크립트 컴포넌트로 엑셀과 유사한 UI에 비슷한 기능으로 보여주고 있습니다.

많은 분들이 쓰시면 유료화 되려나..음..


그래도 아무도 모르게 없어지는것보단 나을거 같아서 공유차 올립니다.

한번 들려보세요.

'언어 > JAVASCRIPT' 카테고리의 다른 글

[JavaScript] 코드 압축  (0) 2018.06.08
JAVASCRIPT 날짜 관련 정리  (0) 2015.12.07
[펌]Memory leak 관리 방법  (0) 2015.12.01
자바스크립트 코드 압축 하기  (0) 2015.11.18
Posted by 까망후니
2015. 12. 1. 17:47


초보 개발자가 Javascript 개발을 하다 보면 가장 많이 부딪히는 문제가 Memory관리이다.

아래의 내용은 기본적인 Memory 관리 방법을 알려주고 있다.

내용은 제가 쓴게 아니고, 퍼온 내용입니다.




Memory leaks


  1. Memory management in JavaScript
    1. Garbage collection example
    2. Circular references collection
  2. Memory leaks
    1. IE<8 DOM-JS memory leak
    2. XmlHttpRequest memory management and leaks
    3. setInterval/setTimeout
    4. Memory leak size
    5. jQuery anti-leak measures and leaks
      1. Leak examples
      2. Leak evasion
  3. Finding and fixing memory leaks
    1. Checking for leaks
    2. Preparing the browser
  4. Tools

In JavaScript, we rarely think about memory management. It appears natural that we create variables, use them and the browser takes care about low-level details.

But as applications become complex and AJAXy, and a visitor stays on a page for a long time, we may notice problems like a browser takes 1G+ and grows larger and larger in size. That’s usually because ofmemory leaks.

Here we discuss the memory management and most frequent types of leaks.

Memory management in JavaScript

The central concept of JavaScript memory management is a concept of reachability.

  1. A distinguished set of objects are assumed to be reachable: these are known as the roots. Typically, these include all the objects referenced from anywhere in the call stack (that is, all local variables and parameters in the functions currently being invoked), and any global variables.
  2. Objects are kept in memory while they are accessible from roots through a reference or a chain of references.

There is a Garbage Collector in the browser which cleans memory occupied by unreachable objects.

Garbage collection example

Let’s create see how it works on the following code:

01function Menu(title) {
02  this.title = title
03  this.elem = document.getElementById('id')
04}
05 
06var menu = new Menu('My Menu')
07 
08document.body.innerHTML = ''  // (1)
09 
10menu = new Menu('His menu'// (2)

Here we have the memory structure:

On step (1), body.innerHTML is cleaned. So, technically, it’s children are removed, because they are not accessible any more.

…But the element #id is an exception. It is accessible as menu.elem, so it stays in memory. Of course if you check it’s parentNode, it would be null.

Individual DOM elements may remain in memory even when the parent is cleaned out.

On step (2), reference window.menu is reassigned, so the old menu becomes inaccessible.

It is automatically removed by the browser Garbage Collector.

Now the full menu structure is deleted, including the element. Of course if there were other references to the element from other parts of the code, then it would stay intact.

Circular references collection

Closures often lead to circular references. For example:

1function setHandler() {
2 
3  var elem = document.getElementById('id')
4 
5  elem.onclick = function() {
6    // ...
7  }
8 
9}

Here, the DOM element references the function directly via onclick. And the function references elemthrough the outer LexicalEnvironment.

This memory structure appears even if the handler has no code inside. Special methods likeaddEventListener/attachEvent also create the reference internally.

The handler is usually cleaned up when the elem dies:

1function cleanUp() {
2  var elem = document.getElementById('id')
3  elem.parentNode.removeChild(elem)
4}

Calling cleanUp() removes elem from DOM. There’s still a reference LexialEnvironment.elem, but there are no nested functions, so LexialEnvironment is recycled. After that, elem becomes inaccessible and cleaned up with it’s handlers.

Memory leaks

Memory leak happens when the browser for some reason doesn’t release memory from objects which are not needed any more.

This may happen because of browser bugs, browser extensions problems and, much more rarely, our mistakes in the code architecture.

IE<8 DOM-JS memory leak

Internet Explorer prior to version 8 was unable to clean circular references between DOM objects and JavaScript.

The problem was even more serious in IE6 prior to SP3 (mid-2007 patch), because memory was not freed even after page unload.

So, setHandler leaks in IE<8, elem and the closure is never cleaned up:

1function setHandler() {
2  var elem = document.getElementById('id')
3  elem.onclick = function() { /* ... */ }
4}

Instead of DOM element, there could be XMLHttpRequest or any other COM object.

IE leak workaround is to break circular references.

We assign elem = null, so the handler doesn’t reference DOM element any more. The circular link is broken.

The partiular leak is mostly of historical interest, but a good example of breaking circular links.

You can read more about it in the articles Understanding and Solving Internet Explorer Leak Patternsand Circular Memory Leak Mitigation.

XmlHttpRequest memory management and leaks

The following code leaks in IE<9:

01var xhr = new XMLHttpRequest() // or ActiveX in older IE
02 
03xhr.open('GET''/server.url'true)
04 
05xhr.onreadystatechange = function() {
06  if(xhr.readyState == 4 && xhr.status == 200) {           
07    // ...
08  }
09}
10 
11xhr.send(null)

Let’s see the memory structure of each run:

The asynchronous XmlHttpRequest object is tracked by the browser. So there is an internal reference to it.

When the request finishes, the reference is removed, so xhr becomes inaccessible. IE<9 doesn’t do that.

There is an separate page example for IE.

Fortunately, fixing this is easy. We need to remove xhr from the closure and access it as this in the handler:

01var xhr = new XMLHttpRequest()
02   
03xhr.open('GET''jquery.js'true)
04   
05xhr.onreadystatechange = function() {
06  if(this.readyState == 4 && this.status == 200) {           
07    document.getElementById('test').innerHTML++
08  }
09}
10    
11xhr.send(null)
12   xhr = null
13}, 50)

Now there is no circular reference, so the leak is fixed. Sample page for IE.

setInterval/setTimeout

Functions used in setTimeout/setInterval are also referenced internally and tracked until complete, then cleaned up.

For setInterval, the completeness occurs on clearInterval. That may lead to memory leaks when the function actually does nothing, but the interval is not cleared.

For server-side JS and V8 see an example of that in the issue: Memory leak when running setInterval in a new context.

Memory leak size

Data structures which leak may be not large.

But the closure makes all variables of outer functions persist while the inner function is alive.

So imagine you create an function and one of its variables contains a large string.

01function f() {
02  var data = "Large piece of data, probably received from server"
03 
04  /* do something using data */
05 
06  function inner() {
07    // ...
08  }
09 
10  return inner
11}

While the function inner function stays in memory, then the LexicalEnvironment with a large variable inside will hang in memory until the inner function is alive.

JavaScript interpreter has no idea which variables may be required by the inner function, so it keeps everything. In every outer LexicalEnvironment. I hope, newer interpreters try to optimize it, but not sure about their success.

Actually, there may be no leak. Many functions may be created for sane reason, for example per every request, and not cleaned up because they are handlers or something.

If the data is only used in the outer function, we could nullify it to save memory.

01function f() {
02  var data = "Large piece of data, probably received from server"
03 
04  /* do something using data */
05 
06  function inner() {
07    // ...
08  }
09 
10  data = null
11 
12  return inner
13}

Now the data still remains in memory as the property of LexicalEnvironment, but it doesn’t occupy so much space.

jQuery anti-leak measures and leaks

jQuery uses $.data API to fight IE6-7 memory leaks. Unfortunately, that introduces new jQuery-specific leaks.

The core principal of $.data is that any JavaScript entity is bound to/read from an element using jQuery call:

1// works on this site cause it's using jQuery
2 
3$(document.body).data('prop''val'// set
4alert( $(document.body).data('prop') ) // get

The jQuery $(elem).data(prop, val) assignment does the following:

  1. The element gets an unique number if it doesn’t have any:
    elem[ jQuery.expando ] = id = ++jQuery.uuid  // from jQuery source

    Here, jQuery.expando is a random key, so there will be no conflicts.
  2. The data is set to a special object jQuery.cache:
    jQuery.cache[id]['prop'] = val

When the data is read from an element:

  1. The element unique number is retrieved from id = elem[ jQuery.expando ].
  2. The data is read from jQuery.cache[id].

The purpose of this API is that a DOM element never references JavaScript objects direclty. It has a number, but that’s safe. The data is in jQuery.cache. Event handlers internally use $.data API also.

But as a side effect, an element can’t be removed from DOM using native calls.

Leak examples

The following code leaks in all browsers:

1$('<div/>')
2  .html(new Array(1000).join('text')) // div with a text, maybe AJAX-loaded
3  .click(function() { })
4  .appendTo('#data')
5 
6document.getElementById('data').innerHTML = ''

Open on a separate page.

The leak happens because elem is removed by cleaning parent innerHTML, but the data remains injQuery.cache. More importantly, the event handler references elem, so both handler and elem stay in memory with the whole closure.

A simpler leak example:

The code below leaks:

1function go() {
2  $('<div/>')
3    .html(new Array(1000).join('text'))
4    .click(function() { })
5}

Open on a separate page.

The problem is: the element is created, but not put anywhere. So, after the function, the reference to it is lost. But it’s jQuery.cache data persists.

Leak evasion

First, one should use jQuery API to removing elements.
Methods remove()empty() and html() check descendant elements for data and clean them. That’s the overhead, but, at least, the memory can be reclaimed.

Actually, if performance is critical, there are tweaks.

  1. First, if you know which elements have handlers (and there are few of them),
    you may want to clean the data manually with removeData() and then you’re safe.
    Now can use detach() which doesn’t clean data or any native method.
  2. If you don’t like the way above, but the DOM tree is large, you may use $elem.detach() and put$(elem).remove() in setTimeout, so it will act asynchronously and evade visual sluggishnes.

Fortunately, finding jQuery memory leaks is easy. Check the size of $.cache. If it’s too large, inspect it and see which entries stay and why.

Now when the topic is (hopefully) clear, in the next sections we are not talking about jQuery leaks.

Finding and fixing memory leaks

Checking for leaks

There are many leak patterns and browser bugs. New browser bugs will appear, because programming is hard.

So, we could meet a leak in HTML5 functionality or any other place. To fix, we should try to isolate and reproduce it first.

The browser doesn’t clean memory immediately. Most algorithms of garbage collection free memory from time to time. The browser may also postpone memory cleanup until the certain limit is occupied.

So it you think you’ve found a problem and run the “leaking” code in a loop, wait for a while.

The browser may grow in size, but eventually free the memory after some time, or when it exceeds the certain value.

Don’t take a minute of increasing memory as a loop proof if the overall footprint is still low. Add something to leaking objects. A large string will do.

Preparing the browser

Leaks may occur because of browser extensions, interacting with the page. More importantly, a leak may occur because of two extensions interaction bugs. It’s like: when Skype extension and my Antivirus are enabled, it leaks. When any of them is off, it doesn’t.

So, the steps:

  1. Disable Flash.
  2. Disable antiviruses. Link checkers and other functions, integrated with the browser.
  3. Disable plugins. All plugins.
    • For IE, there is a command-line parameter:
      "C:\Program Files\Internet Explorer\iexplore.exe" -extoff
      

      Also disable third-party extensions in IE browser properties.


    • For Firefox, run it with clean profile. Use the following command to run profile manager and create a fresh empty profile.
      firefox --profilemanager
      

Tools

In Chrome developer tools, there is a Timeline - Memory tab:

We can watch the memory occupied by it.

There is also Profiles - Memory, where we can take a snapshot and see what’s inside. Snapshots can be compared to each other:

Most of time, it doesn’t tell you anything. But at least you can see which objects are piling up, and probably the structure of the leak.

Memory leaks are hard. One thing you certainly need when fighting them.




Posted by 까망후니
2015. 12. 1. 15:38

CentOS 설치하면서 Tomcat 및 각종 설정 하는 방법이 잘 정리된 사이트 입니다.

OS 설치하고, Tomcat 설치하고, DB 설치하고..등등..

여러 사이트 정보 조합하다보면 엉망으로 설정이 잡힐때가 있는데, (뻥인 사이트도 많구요..)


여기는 그래도 내용들이 잘 되는것 같아서 올려 봅니다.


CentOS6 와 CentOs7도 올라가 있고, 다른 많은 정보들이 있습니다.


URL : http://www.server-world.info/en/note?os=CentOS_7&p=tomcat8

Posted by 까망후니
2015. 12. 1. 15:32
[펌]http://stg.etribe.co.kr/2014/08/08/centos-6-5-%EC%BB%A4%EB%84%90-%EC%97%85%EB%8D%B0%EC%9D%B4%ED%8A%B8-%ED%95%98%EA%B8%B0/
아래의 내용은 제가 CentOS 커널을 업데이트 하는 방법을 잘 몰라서 검색한 내용을 발췌한 내용입니다.
위의 URL을 가시면 전문이 있습니다.

참고로 CentOS의 커널 버전을 업그레이드 한 이유는 Centos6.x 버전의 리눅스 커널에서 의문의 다운 현상이 지속되어서 입니다.

해당 다운 현상은 커널 버전으로 판단되어 업그레이드 하였으며, 이후 문제 없이 사용하고 있습니다.
(커널 버전은 생각도 안하고 개고생했습니다...ㅠ.ㅠ.)

-설치 환경

OS : CentOS 6.5

커널 버전 : 2.6.32-431.23.3.e16.x86_64

-업데이트 순서

커널에 필요한 패키지 설치 및 업데이트

원하는 버전의 커널 다운로드

커널 컴파일 및 환경 설정

커널 적용

재부팅 및 작동확인


1. 커널에 필요한 패키지 설치 및 업데이트.

일단 현재 커널 버전을 확인해 봅니다.

커널확인

현재 패키지에는 현재 커널이 맞을수가 있습니다.

그래서 최신커널 업데이트 전에 모든 패키지를 업데이트 합니다.

#yum update

커널 업데이트 중 make menuconfig 라는 명령어를 통해

환경설정을 하게 되는데

이때 화면들이 깨지거나 제대로 알아보기 힘든 상황을 피하기위해

ncuses-devel 이란 라이브러리를 인스톨 합니다.

#yum install ncurses-devel

그리고 커널 설치시 필요한 패키지들이 묶여있는 그룹패키지를 설치합니다.

#yum groupinstall “Development Tools”


2. 설치를 원하는 버전의 커널을 다운로드 

https://www.kernel.org/pub/linux/kernel/v3.x/

저 주소로 가면 여러 버전의 커널이 나열되있는걸 볼수 있습니다.

제목 없음

전 일단 가장 최신버전을 받아봅니다.

/var의 경로로 다운로드를 해봅니다.

#cd /var

#wget http://www.kernel.org/public/linux/kernel/v3.x/linux-3.16.tar.gz

(혹시 wget 명령어가 먹히지 않으면 #yum -y install wget 으로 다운로드패키지를 설치합니다.)

받은 파일의 압축을 풀고 링크 설정

#tar xvzf linux-3.16.tar.gz

#cd /usr/src/

#ln -s /var/linux-3.16 linux


3. 커널 컴파일 및 환경 설정

make 명령어를 통해 컴파일과정을 거쳐 환경설정을 합니다.

#cd /usr/src/linux

#make mrproper

#make clean  //커널컴파일을 위해 소스파일들의 찌꺼기(?)를 정리

#cp /boot/config-‘uname -r’ ./.config  //현재 리눅스의 커널 설정파일을 이용해

3.16버전의 컴파일할 소스파일 복사

(‘uname -r’ 이 안먹힐때가 있더군요 그럴땐그냥 파일이름으로 대체하시면됩니다.)

#make menuconfig  //업데이트할 커널의 설정변경을 위한 툴 실행

제목 없음

설정화면이 보이면 일단 Load 메뉴를눌러 .config 소스 파일을 받아옵니다.

소스파일 로딩이 완료되면 General setup 항목을 선택합니다.

제목 없음

Enable deprecated sysfs features to support old userspace too

라는 항목을 <space bar> 를 이용해 체크해줍니다.

하단에 Save메뉴를 통해 저장 100%까지 게이지가 차는걸 확인한후 Exit로 빠져나옵니다.

설정파일을 이용하여 커널빌드 및 컴파일 합니다.

#make all

//”.config” 설정파일을 이용하여 커널소스 빌드(꽤 시간이 걸립니다.)

저는 이과정에서 한참지난후 알수없는 에러로 인해 리눅스를 다시 깔았던….기억이…ㅜㅜ

#make modules_install

//커널 소스 빌드내용을 모듈로 설치

#make install

//커널 설치


4. 커널 적용

리눅스 부트로더인 grub.conf 파일을 열어서 내용을 확인합니다.

#vi /boot/grub/grub.conf

제목 없음

파란 상자 안에 내용이 커널설치후 자동으로 입력된 값입니다.

제가 업데이트할때까지만해도 3.15가 최신이었어서 캡쳐본은 버전이 3.15네요.

빨간 상자 안에 값을 보시면 원래 default=1이 주석 처리 되있었는데

제가 커널적용을 위해 default=0을 주석처리하고 1번으로 변경한 내용입니다.

 


5. 재부팅 및 작동확인

재부팅후 제대로 반영됐는지 확인해 보겠습니다.

제목 없음

반영이 잘 된것 같습니다.


Posted by 까망후니