That day I received heapdump from production as it is usually done when application runs out of memory. I was 100% confident that was leaking Appdynamics agent (we got that issue several times already on multiple services), so I was like 'eehh, i won't even bother opening MAT', but still I had to attach report and analysis to jira ticket. Was I surprised when I actually saw no real leak suspicions? I looked into AppDynamics and saw quite strange picture of garbage collection, so my first resort was -- G1 will do the trick. It didn't help. (well, that actually increased lifetime of an application for 1 more day :)). Okay, what next? We checked java version on production and decided that we should update it, cause it was about half a year old. That also didn't help. At this point I started looking into Automatic memory leak detection in Appdynamics. When it was turned on it clearly said that half of memory was occupied by netty's Recycler objects. We turned it off, it didn't help. The most strange thing for me was that I was not quite sure that it was heap memory leak or not. Our architect found a great article about native memory leak detection using jemalloc: Using jemalloc to get to the bottom of a memory leak. I tried that at stage environment and no luck -- it showed me nothing! I was desperate. So we decided to try that on production! After one day of running we got a nice report:
The boldest lines are the code blocks that have allocated more native memory then others. The picture clearly states -- I should search for MethodHandles and Exceptions. 5 minutes searching for the first one in the project libraries and I knew that feign and spring-data-commons are using that for supporting default methods on their interfaces. We were not using default methods in our Feign clients, but we were using extensively default methods in our Spring Data Repositories. Ahhha!! That was it -- DATACMNS-1074. It also explained the second bold line with exceptions. Fix was simple (we didn't want to update libraries) -- remove default methods.
Thanks Jason Evans for jemalloc.
BTW j stands for Jason not java ;)
Java extended
четверг, 18 января 2018 г.
пятница, 24 июля 2015 г.
Interview task
Problem: Count the most frequent k-mers in a text
Input: A string text and an integer k
Output: All most frequent k-mers in text
Term k-mer refers to a string of length k. A k-mer pattern is a most frequent k-mer in a text if no other k-mer is more frequent than pattern.
Example:
1. AATTT is a most frequent 5-mer in text: acaAATTTgcatAATTTcgggaAATTTcct
Note: Count(CGATATATCCATAG, ATA) is equal to 3 (not 2) since you should account for overlapping occurrences of Pattern in Text.
k = 4
Text:
atcaatgatcaacgtaagcttctaagcatgatcaaggtgctcacacagtttatccacaac
ctgagtggatgacatcaagataggtcgttgtatctccttcctctcgtactctcatgacca
cggaaagatgatcaagagaggatgatttcttggccatatcgcaatgaatacttgtgactt
gtgcttccaattgacatcttcagcgccatattgcgctggccaaggtgacggagcgggatt
acgaaagcatgatcatggctgttgttctgtttatcttgttttgactgagacttgttagga
tagacggtttttcatcactgactagccaaagccttactctgcctgacatcgaccgtaaat
tgataatgaatttacatgcttccgcgacgatttacctcttgatcatcgatccgattgaag
atcttcaattgttaattctcttgcctcgactcatagccatgatgagctcttgatcatgtt
tccttaaccctctattttttacggaagaatgatcaagctgctgctcttgatcatcgtttc
Input: A string text and an integer k
Output: All most frequent k-mers in text
Term k-mer refers to a string of length k. A k-mer pattern is a most frequent k-mer in a text if no other k-mer is more frequent than pattern.
Example:
1. AATTT is a most frequent 5-mer in text: acaAATTTgcatAATTTcgggaAATTTcct
Note: Count(CGATATATCCATAG, ATA) is equal to 3 (not 2) since you should account for overlapping occurrences of Pattern in Text.
k = 4
Text:
atcaatgatcaacgtaagcttctaagcatgatcaaggtgctcacacagtttatccacaac
ctgagtggatgacatcaagataggtcgttgtatctccttcctctcgtactctcatgacca
cggaaagatgatcaagagaggatgatttcttggccatatcgcaatgaatacttgtgactt
gtgcttccaattgacatcttcagcgccatattgcgctggccaaggtgacggagcgggatt
acgaaagcatgatcatggctgttgttctgtttatcttgttttgactgagacttgttagga
tagacggtttttcatcactgactagccaaagccttactctgcctgacatcgaccgtaaat
tgataatgaatttacatgcttccgcgacgatttacctcttgatcatcgatccgattgaag
atcttcaattgttaattctcttgcctcgactcatagccatgatgagctcttgatcatgtt
tccttaaccctctattttttacggaagaatgatcaagctgctgctcttgatcatcgtttc
понедельник, 16 июня 2014 г.
ДСТУ ГОСТ 7.1:2006 и Latex
Настало время и мне стать магистром. Оформлять диссертацию я решила в латехе, т.к. уже имелся опыт в оформлении бакалаврской работы. Но почему-то а это время некоторые госты успели поменяться (или просто всем было наплевать на бакалаврскую). Изменение оформления литературы, а именно теперь необходимо использовать ДСТУ ГОСТ 7.1:2006, который, увы, нигде не оформлен в библиографических стилях. Ранее я пользовалась пакетом gost. Особо заморачиваться с написанием нового стиля не хотелось. Тем более, что фактически от нас требовалось следующее оформление вне зависимости от типа источника:
Первый автор. Название / Первый автор. Второй автор. Третий автор. [вся ерунда дальше]
Собственно, в самом госте:
добавляем:
FUNCTION {first.author}
{
author
#1 "{vv~}{ll}{~jj}{~ff}" format.name$ add.period$ output new.sentence
}
Ищем необходимые нам типы источников. (для меня это был article) Например, FUNCTION {article}
Заменяем всю функцию на:
FUNCTION {article}
{
output.bibitem
first.author
format.title add.medium "title" output.check
new.slash
author.before
author.after
new.dblslash
journal emphasize add.doi "journal" output.check % new in v.2
new.block
format.date "year" output.check
new.block
format.volume output
format.number output
new.block
format.pages.page output
new.block
note output
new.sentence
output.eprint.url
format.annote output
fin.entry
}
По аналогии можно сделать изменения и в других типах источников.
Очень хорошая книга в тему: Tame The Beast
И пример:
Первый автор. Название / Первый автор. Второй автор. Третий автор. [вся ерунда дальше]
Собственно, в самом госте:
Основна назва [Загальне
позначення матеріалу] = Паралельна
назва : відомості,
які відносяться до назви / відомості
про Авторство чи Відповідальність
;
про інших Осіб.
– Відомості про повторність видання / Відповідальність
за видання. – Зона специфічних відомостей.
– Місце видання : Вид-во, рік.
– Фізична (кількісна) характеристика. – (Серія
і підсерія ; №, т.). – Примітки
(додаткова інформація від бібліографа,
напр.: системні вимоги до електрон. ресурсів). – ISBN.
У новому стандарті, за міжнародною практикою бібліографічних
записів, у заголовках творів одного, двох і трьох авторів зазначається ім’я
першої особи без слів “та ін.” Причому, воно обов’язково повторюється у зоні
відповідальності за видання у точності до форми запису на
титульному аркуші.
У меня в ссылках были только article, inproceedings, book. В примерах оформления есть только "тези з конференції", "книжка" из того, что подходит мне. К сожалению, я так и не поняла относится ли "журнал" или "газета" к article.
А теперь ближе к делу. за основу берем ugost2008.bst. Выкачиваем его из интернетов, кладем в папку с нашим основным tex файлом (можно положить bst файлы и в другое стандартное место, но это можно и нагуглить ;)). Лучше его и переименовать сразу же в какой-то ugost2008-dstu-adapt.bst. Соответсвенно названию в нашем основном tex файле должно быть следующее:
\bibliographystyle{ugost2008-dstu-adapt}
\bibliography{thesis-refs}
Теперь изменяем ugost2008-dstu-adapt.bst.добавляем:
FUNCTION {first.author}
{
author
#1 "{vv~}{ll}{~jj}{~ff}" format.name$ add.period$ output new.sentence
}
Ищем необходимые нам типы источников. (для меня это был article) Например, FUNCTION {article}
Заменяем всю функцию на:
FUNCTION {article}
{
output.bibitem
first.author
format.title add.medium "title" output.check
new.slash
author.before
author.after
new.dblslash
journal emphasize add.doi "journal" output.check % new in v.2
new.block
format.date "year" output.check
new.block
format.volume output
format.number output
new.block
format.pages.page output
new.block
note output
new.sentence
output.eprint.url
format.annote output
fin.entry
}
По аналогии можно сделать изменения и в других типах источников.
Очень хорошая книга в тему: Tame The Beast
И пример:
суббота, 8 сентября 2012 г.
Enums and annotations
Personally I have never used these Java features. But they might not be surprising to you.
enum BeadType {
ROUND_BEAD(10, 10),
CYLINDRIC_BEAD(10, 15),
OTHER_BEAD(20, 20);
private final int width;
private final int height;
BeadType(int w, int h) {
this.width = w;
this.height = h;
}
public int getW() {
return width;
}
public int getH() {
return height;
}
}
I really like it.
The first one
Enum defines a class, so I can use it just like any normal class: create constructor, add methods, fields and so on. For example:enum BeadType {
ROUND_BEAD(10, 10),
CYLINDRIC_BEAD(10, 15),
OTHER_BEAD(20, 20);
private final int width;
private final int height;
BeadType(int w, int h) {
this.width = w;
this.height = h;
}
public int getW() {
return width;
}
public int getH() {
return height;
}
}
I really like it.
The second one
Annotations. I suppose, that almost everyone has at least once used @Override annotation. But did you know that you can create your own type of annotation and even make it to be documented in your Javadoc-documentation (just add @Documeted before your own annotation definition). I was surprised!
@Documented
@interface MyAnnotation {
String myName();
int myAge();
String email();
}
@MyAnnotation(
myName = "Nastya",
myAge = 20,
email = "zminyty@gmail.com")
воскресенье, 4 марта 2012 г.
Closable java tabs
There is no predefined JTabbedPane in Java with closable tabs, so I decided to make it myself.
No doubts, there are a lot of variations of doing this with standard close icons. I wanted to make it in such a way, that only when you double click on tab - it closes.
Code:
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import javax.swing.SwingUtilities;
/**
*
* @author Aloren
*/
public class CloseTabbedPane extends JTabbedPane {
public CloseTabbedPane() {
super();
tabbedPane.addMouseListener(new CloseMouseListener(handler));
}
private static class CloseMouseListener extends MouseAdapter {
int oldIndex;
public CloseMouseListener() {
}
@Override
public void mouseClicked(MouseEvent e) {
CloseTabbedPane pane = (CloseTabbedPane)e.getSource();
int i = pane.indexAtLocation(e.getX(), e.getY());
if (e.getClickCount() == 2) {
if (i != -1) {
pane.remove(i);
if (pane.getTabCount() == 0) {
((JFrame) SwingUtilities.getRoot(pane)).dispose();
System.exit(0);
}
}
} else {
pane.getModel().setSelectedIndex(i);
}
}
}
}
No doubts, there are a lot of variations of doing this with standard close icons. I wanted to make it in such a way, that only when you double click on tab - it closes.
Code:
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import javax.swing.SwingUtilities;
/**
*
* @author Aloren
*/
public class CloseTabbedPane extends JTabbedPane {
public CloseTabbedPane() {
super();
tabbedPane.addMouseListener(new CloseMouseListener(handler));
}
private static class CloseMouseListener extends MouseAdapter {
int oldIndex;
public CloseMouseListener() {
}
@Override
public void mouseClicked(MouseEvent e) {
CloseTabbedPane pane = (CloseTabbedPane)e.getSource();
int i = pane.indexAtLocation(e.getX(), e.getY());
if (e.getClickCount() == 2) {
if (i != -1) {
pane.remove(i);
if (pane.getTabCount() == 0) {
((JFrame) SwingUtilities.getRoot(pane)).dispose();
System.exit(0);
}
}
} else {
pane.getModel().setSelectedIndex(i);
}
}
}
}
Подписаться на:
Комментарии (Atom)

