« first day (447 days earlier)      last day (3586 days later) » 

12:01 PM
ThreadLocals are a nice trick..... there is no need for synchronization.... and the variables that you get/set are actually stored on the thread object itself
(the thread that is calling the set/get)
 
that's a real nice trick then
I'm still a bit confused on where to call the setid
When I am on the thrad, so I suppose right before fileConsumer.accept(path.getPath())?
 
If you have a thread that processes a path, the very first thing you di is set the threadlocal.
then, anything on that thread will have access to that value from that point on
when you are done processing it, you set it to null...
 
I do need to make some kind of helper log method then I suppose?
 
so that you don't confuse anything
 
monking
 
12:03 PM
Unless I can inject it into the logger.xxx
It's a bit ugly, but I prefer legit code to hacks, I just didn't know how to do it
 
You may want to create a 'full class' of information for the document, like the Path, name, id, other things, and store that class instance in the thread-local, and then make the getters static .... let me show you....
 
I learned something (else) new as well right now!
Which is awesome
suppose for whatever reason my standard value would be "null"
I coudl then use: private final static ThreadLocal<String> ID = ThreadLocal.withInitial(() -> "null");
Finally rid of that inner class creation
 
public final class DocumentContext {

    private static final ThreadLocal<DocumentContext> docid = new ThreadLocal<>();

    public static void setThreadContext(DocumentContext id) {
        docid.set(id);
    }

    public static DocumentContext getThreadContext() {
        return docid.get();
    }


    private final String id;
    private final File source;
    private final int xxx;

    public DocumentContext(String id, File source, int xxx) {
        super();
        this.id = id;
        this.source = source;
 
I don't think there is a point in having that now, but I do see the possibilities.
 
You should know that this is not the best solution.... the best solution would in fact be a context that you pass to each method call......
 
12:11 PM
I think that is pollution of the method signatures
 
so you would not be able to use thread-pools inside the thread again, etc.
unless you manually moved/copied the context on to the next thread.
@skiwi - you using log4j?
 
Yep
 
0
Q: List Comprehension in Pythonic answer to LPTHW ex48

MikeiLLNew to Python and loving the my newly found ignorance of generators, list comprehensions and more. I'm not really seeing any use for a generator here, unless there's some way to hook a generator into a language dictionary. But in the following code, the longhand version of the if statement (typ...

 
@rolfl Why?
Do you think a custom appender can pick up the document id from the CurrentDocumentContext when I log?
 
0
Q: Python - Minesweeper

ThatBoredPenguinI'm new to Python (and generally to programming), and I have recently written this Minesweeper game: import random import string import os class Square(object): """Represent a square in the cell. mine -- if the square has a mine, it's True. Otherwise, False. location -- a tuple that...

 
12:26 PM
@skiwi Did you not see the link I added right below that?
11 mins ago, by rolfl
http://logging.apache.org/log4j/2.x/manual/thread-context.html
 
@CaptainObvious Looks like a good first question.
 
Greetings, Programs.
 
@Donald.McLean Greetings, User
3
 
12:41 PM
@rolfl I saw it, but I thought it was the project page of log4j 2.x :P
That's exactly what I meant, thanks @rolfl.
@Donald.McLean It's also what you meant a few days ago when we discussed logging
Without needing to write the custom appender.
 
so...tired...
 
Took you 2 hours to type that message, so tired...?
 
no, where did you get the 2 hour figure from?
 
You were on the active users list for like 2 hours I think :p
 
odd...I only got back from dinner about an hour ago
 
12:47 PM
might've also been an hour
was a joke either way :P
how come tired
 
@skiwi Cool. I'm glad you found a solution that works for you.
 
slept very, very badly a few nights ago, and still haven't caught up
 
@Donald.McLean I suppose it'll work, still need ot implement it though ;)
 
@skiwi One of my side projects is a log analysis tool, since logs are my primary means of debugging.
 
@Yuushi poor you... usually I don't sleep longer than 5 hours on weekdays, and the last two months I couldn't catch up on weekends...
 
12:51 PM
@rolfl This is also obsolete now since I'm using log4j2?
Interesting there @Donald.McLean log analysis
 
@Vogel612 I wasn't making it into a competition :P
 
@skiwi - yes, obsolete, but, it was how I would have solved the problem, and that is what made me search for existing solutions.
and it's what the log4j does.
 
@skiwi I can't use existing tools because a) my log files are too large and the existing tools are non-performant; b) none of the existing tools can recognize my transactions.
 
@Yuushi did you try to coffee the tiredness yet?
 
so, not obsolete, but reinventing the wheel
 
12:53 PM
Ah, it's just your thought process ;)
 
(not that it helps much with my deficit)
 
@Donald.McLean Is it still the telescope data? Or some other internal project
 
@Vogel612 it's almost 10:30pm here, so I've given up on coffee for the day
 
@Yuushi nvm then. y u no head 2 bed?
3 pm here.
 
doesn't matter how tired I am, I can never sleep before 12...usually more like 1
 
12:54 PM
@skiwi - what I did was this: https://www.google.ca/search?hl=en&q=create a log context for a thread
 
@Yuushi similarly... mostly it's 2 here, sometimes 2.30
 
@skiwi Yes, I work on a back-end control system for the archive: archive.stsci.edu
 
@Vogel612 Yeah...some people will just always be night owls
 
@Donald.McLean About what amount of data are we taling there? Log files of TB's?
@rolfl I think I was missing the word context in my searches I've done so far
 
@skiwi I'm not doing sysadmin/web server tuning kind of analysis. I'm using logs as a debug tool. The existing tools for this kind of work don't even handle megabytes well.
 
12:59 PM
ah
 
@Donald.McLean Written in Scala?
 
If this works, then I only got a big ass memory leak to figure out :/
 
Good morning everyone!
 
Monking @Marc-Andre!
 
Monking @Marc-Andre. How many birds are on the wall?
 
1:19 PM
Hello.
 
@Yuushi Well, yeah. What else would I use?
 
@Vogel612 I don't even know anymore what are our goals :P ! I've completely lost track of our race! I'm really sorry!
But one thing I'm glad is that I'm still participating because of our race! And you seems to have earn a lot of rep ! So it's positive :D
 
@Donald.McLean Indeed, but I was just curious
 
@Marc-Andre you were aiming for 4k, I was for 5 ;)
 
Unless there is a miracle... I think you will win :P
 
1:35 PM
I'm starting to feel that I'm perhaps not smart enough to be a programmer. It's been FREAKING HOT lately and not until today I go down to the cellar and pick up my fan...
2
 
@SimonAndréForsberg congrats on the 20k!
 
@Marc-Andre Thanks!
 
@SimonAndréForsberg What's "FREAKING HOT"?
 
@SimonAndréForsberg Can confirm, a real programmer would've made a program to pick up the fan and put it there.
 
@Yuushi About 35 °C
 
1:38 PM
@SimonAndréForsberg Yeah that's pretty warm
 
@skiwi Why didn't I think of that?
 
@skiwi challenge you to raise: A real programmer would'be made a program to write a program that picks up the fan!
 
@Yuushi Australia-warm? Or still too cold to be Australia?
 
plenty warm enough for me....I actually hate really hot weather
 
@Yuushi Normally I like hot weather. But recently it's been a bit too hot. I kinda miss the rain and thunderstorms we had some weeks ago
Typical Swedish behavior, always complaining about the weather. Never happy.
@Vogel612 I guess there are not real programmers.
 
1:41 PM
I think that happens in every single country
 
@SimonAndréForsberg Dutch can confirm.
Time to rebuild everything here and hope it doesn't give an OOM now.
 
is someone serialing me???
 
@Vogel612 Serializing?
 
getting small driplets of upvotes on recent answers...
 
<-- catching up on java and everything post
 
1:43 PM
lol...
nevermind, carry on then..
 
I think I also got an upvote recently!
 
Well you're posting in java, so you may have receive some attention ;)
 
Holy, this monitor looks nice
 
1:59 PM
I guess the price does not look that nice to my budget!
 
450 pounds...
Not really cheap, but not over expensive either
 
Well 900 Canadian $ is really not in my target price :P
 
:P
I absolutely do not get this Java memory leak I'm having.
It's using currently 6GB in Windows, usage is steadily increasing, it will never drop again.
But sampling/profiling tells me that it's only using like 250-500MB of data
Garbage collecting doesn't reduce it.
Eventually it will crash around 8GB with an OOM exception, probably due to other programs and having no pagefile available
Even the heap size is just 500MB
 
@skiwi - Do you know what the most common cause of Java "memory leaks" is? (I do)
 
@Donald.McLean Nope
This is (one of my) first time working with a server application
 
2:08 PM
0
Q: Duplicate code in similar classes where i cannot add more inheritance, Is there a better way of doing this?

Lex WebbI'm building a .NET Linq-esc query builder for my application and i'm wondering about my implementation and code structure when it comes a few classes. Basically i'm creating a query builder for SQL, and i need for my classes to be able to using the following behavior: query.Select(...).From(.....

 
That works with big amounts of data
 
@skiwi Allocating something, and putting it in some kind of widely used data structure, and then forgetting to take it back out so it can be garbage collected.
 
@Donald.McLean But that should show up when profiling the memory structure, right?
 
Caches, event registrations, things like that.
 
I think something went wrong with interacting with a C API
and I'm leaking there
 
2:10 PM
@skiwi You're making native calls?
 
Yep
 
That would certainly explain it.
 
I'm still unsure of how I should clean them up
And I presumably am forgetting to do so on important objects
But a normal profiler such as JVisualVM does not cut it then?
 
Pretty sure the Java profiler can't profile native C code
 
So I should digg into that part
 
2:13 PM
Freeing up memory in C is a much more complex task than just letting go of it and hoping the garbage collector catches it
(because there is no garbage collector in c)
what are you calling? the API should provide some way to clean up it's junk
 
I'm aware of that
 
Too bad I couldn't have posted that code review here and gotten some rep for it. It was a dusy.
Ay yai yai.
 
@skiwi sorry :) Just used to having to explain C to a bunch of Java progs
> What do you mean we have to allocate our own memory?!
 
@skiwi No, you would need a native profiler
 
@Ampt No problem, it's still my fault for not caring more about it than I should've.
Oh damn, I lost my stack traces when logging errors with log4j2
Ah should've read the documentation, though the amoutn of overloads log4j2 provides doesn't help either
baseLogger().error("Exception", ex); this feels a bit silly, but oh well
[ERROR] [2014-07-25 16:07:44] [pool-3-thread-2] [2459] [OrganizationConsumer] java.lang.IllegalArgumentException: Field vatNumber cannot be validated: <hidden>
At least I have my document Id now!
 
2:21 PM
0
Q: Producer consumer problem consuming data using transferFrom, Java

user3804236I have a producer consumer problem where multiple threads download a segment of file and write it into buffer these buffers along with location in file where the will be written are passed into a queue using "queue.put" until end of stream has reached. These blocks are written to file in consumer...

0
Q: A better way to do LINQ projections

AetherixI was wondering if there's a better way of doing LINQ projections than what I'm doing below. This method is one of many methods creating a view of an object tree. The first thing that I don't like is that I'm returning an anonymous object. Should I create a BreakdownReport class or something els...

 
@Ampt Do I need to delete all my "pointers"?
Like Pointer<TessBaseAPI> api = TessBaseAPICreate();
Which in the C API is just a TessBaseAPI*
 
@skiwi pointers are fine, you need to free up the memory they are pointing at
 
Hmm
I'm trying to understand it
I understand that things like malloc or variants need to be cleared
 
unless you're storing those pointers in the heap somewhere (like inside of a struct that you allocated memory for)
ok, so there are two memories in C. The stack (where local vars go and are destroyed when you leave their scope) and the heap, where you allocate memory and it stays there until you deallocate it
a good rule of thumb is that for every malloc, there is one free, hopefully within the same scope
if you try and free something twice, you usually cause a crash due to trying to access memory you shouldn't be
if you have too few, you leak memory like you're experiencing
 
Okay..
I'm also needing to understand the other API I'm using
TessBaseAPIInit2(api, Pointer.pointerToCString(dataDirectory.toString()), Pointer.pointerToCString(language), OCREngineMode.DEFAULT);
Pointer.pointerToCString*does* allocate memory then?
 
2:28 PM
hrm... I would have to dig through the doc. So all of your C methods are hidden in java calls then?
you don't actually see any C code do you?
 
Yep
That's a tricky part
 
ok, well thats helpful. It sounds like we're missing a call somewhere to tell the API to clean up
what API reference are you using?
 
@skiwi Hopefully the API should tell you when it is your problem to clean up heap allocated memory
 
I'm trying to find the source file
But seems half of it is auto generated, I'm quite clueless
 
Monking!
 
2:36 PM
Monking @Phrancis
 
Happy Friday, also.
 
looks like most everything is supposed to be automatically de-allocated
at least according to the comments
 
looks like you want public synchronized void release()
that being said, Java generated with macros...blargh
 
I haven't dived into the source so far until now, and it does horrify me yep
Seeing my only data structures so far are I believe strings, I better release all of those
 
@Phrancis Monking!
 
2:40 PM
Still haven't found the source of Pointer.pointerToCString though
Thanks, netbeans... "Cannot open (missing source?)"
 
Hey I posted this very late last night () to DBA, would anyone mind to upvote it if possible? My rep on there is pretty absymal right now :)
1
Q: Schema design for small media production

PhrancisI have been recommended to post this here by my fellow programmers on Code Review SE. I'm designing a database and this is Version 3 of PsychoProductions management tool project I would like to submit this for DBA review. I refactored it from MySQL to PostgreSQL after finding out some of the li...

 
Normally you at least see the bytecode of the method
@Ampt Where did you find that?
 
@skiwi most of the comments over the built in macros and the java mention either a releaser to free the allocated memory for garbage collection, or that it will automatically be freed upon garbage collection
 
@Ampt I did read something about it... but withotu other documentation I do not trust it too much
 
haha true
is there any implementation guide that you followed?
 
2:54 PM
Nothing more than a bunch of examples on another library
which is still in development
 
import org.bridj.Pointer;
import static org.bridj.Pointer.*;
...
public static native void someFunc(Pointer<Float> values);
...
Pointer<Float> array = allocateFloats(10);
float value = array.get(4);
someFunc(values);
array.release();
thats some sample code provided
so apparently you need to call release on your objects to clean them up?
 
So they want the user to manually release it
 
that's what Im gathering
 
0
Q: Query for multiple timeframe in mongoose

DrakaSANHere is the code I use to query the number of view (separated by new users and non-new users) with mongoose. function query_month(i, data, callback) { query = M_logs.aggregate([ { "$match" : { "time" : { "$gt" : new Date(now.getFullYear...

 
Then I guess I'll have to do so :)
I don't think the automatic releasing via GC works, at all, in Java
I'll just be sure to manually do it, then the resources are also freed up faster
Polluting my source code even more with "unnecessary" (Java-style) code :)
 
3:00 PM
hahaha sounds like a ton of fun! You could always dig into the class and add it to the final method call before GC ;)
 
I'm not using them too much luckily
 
16
A: When and how are classes garbage collected in Java?

Joachim SauerA class in Java can be garbage-collected when nothing references it. In most simple setups this never happens, but there are situations where it can occur. There are many ways to make a class reachable and thus prevent it from being eligible for GC: objects of that class are still reachable. t...

put it in the finalize method!
(Or, probably, don't. Playing with how stuff is GCed can be not so fun to hunt down when it doesn't work properly)
 
Doesn't work that way in my case
Not dealing with my own classes
It's currently a very long method call with abstractions to helper methods from time to time
 
well it's probably safer to keep track of it all yourself anyway
this is the wrath of the programming gods for calling native C from within java
 
I can see the memory piling up right now if entire images weren't being freed
Memory leaks of a few bytes per run probably don't hurt
 
3:10 PM
@skiwi famous last words :)
2
*3 weeks later*
I'll just set it up to do batch processing on anything in this folder, saving me time from having to start it and stop it every time!
 
0
Q: How to optimize the following recursion elimination (using a trampoline)

JohanI've translated the following java code, see: https://gist.github.com/pkukielka/2842475 Into this Delphi code: unit Trampoline; interface type ITrampoline<T> = interface function Get: T; function Run: ITrampoline<T>; function Execute: T; end; TTrampoline<T> = class(TInter...

 
@CaptainObvious a trampoline???
 
@skiwi If it's a server, and servers are expected to run flawlessly for weeks, if not months, then even a few bytes here and there will eventually kill you.
 
I may need to reconsider my statement then :P
It's nothing that bad though if it really crashes
But I think that the API does clean up single-value pointers
Hence why I don't want to spend too much time on those
but any strings or arrays I need to clean up.
 
0
Q: Is it pythonic to create side effect inside list comprehension?

user49871I am trying to generate a pascal triangle table in python3. I started to like using this following pattern when dealing with 2D arrays. Generate a list of valid indices Use a function that work with those indices in a list comprehension. (may produce side effects) I wonder, is this pattern py...

0
Q: Variable assignment inside condition

kihuGiven this function: function myFunc(arg) { var result = []; if(arg === 0){ result = false; } return result; } I'd like to perform some stuff based on what this function returns, i.e. I'd like to use the return value as both condition and input for other functions. Th...

 
3:19 PM
@skiwi Or even just pre-emptively restart it every few days, if there's a convenient time to do so.
 
@Donald.McLean It shouldn't hurt things to restart, so I guess time can be found
 
@Phrancis Trampolines are a technique for implementing complex control flow. We have a central dispatch loop that calls a function. This function then returns the next function (“thunk”) to execute back to the dispatch loop. Compare: Continuation-Passing Style.
 
0
Q: T-SQL: delete from multiple tables using temp table variable

Cees TimmermanI'm previewing the data i'm about to delete, but this SQL looks a little redundant; is there a better way to write this? declare @history table(pid int) insert into @history select pid from plans p where p.pidSynergy = 'P0022' and p.pid != 2885 select * from forecast_FTEs where pid in (select p...

 
Testing time now!
Hoping those fixes helped
Contrary to in the past, I now see the memory increasing and also slowly decreasing
 
@amon interesting
 
3:31 PM
Since our site exploded with FizzBuzz questions lately: dominickm.com/?p=514
 
Single letter identifiers and variable names are the devil incarnate I saw someone invoke the devil by using a script with single letter only, it was horrible! — Marc-Andre 4 mins ago
2
Was it on Code Golf @Marc-Andre?
 
0
Q: Stopwatch template

EdwardIt's often useful to be able to time code, for instance, to evaluate alternative approaches to the same problem. Because this is a thing I use frequently, I have created this Stopwatch templated class that I'd like for you all to review. Unlike some other recent code, this class is intended to b...

 
Darn this, I think it's still leaking memory.
 
Any more upcoming answers for this? Otherwise I'm probably going to accept @vnp's answer soon.
 
The future's so bright, I have to wear shades: gizmodo.com/…
 
3:47 PM
Can someone look at my friend's first CR answer and see if you think it is good?
 
Beat me to it. Welcome to Code Review. — ckuhn203 48 secs ago
 
I cannot stand that this memory leak is still there after fixing it.
 
@GreyFox welcome to The 2nd Monitor :)
 
@skiwi "fixing"
 
What's the min rep to be able to chat here?
I thought it was 20
 
4:00 PM
pretty sure it is
 
The FAQ says it is 20 so my guess is 20.
 
(at least on the other sites it is)
 
(I've just joined and it told me that the minimum is 20, so I am fairly certain this information is valid)
 
It is 20 according to the privlidges page.
 
0
Q: Need a help to write code in loginBean.java...Please help me

javadevelperCan you please review my below code which i have written userDao.java ,userbean.java, userService.java but i am not able get how to proceed further in loginBean.java. For the below requriement "need to pass customer id to the method in dao,get the bigdecimal and set it in userbean , the pass AAL...

 
4:05 PM
0
A: Delete from multiple tables using temp table variable

PhrancisTable Variable? I think you don't need this table variable @history why not instead do all this within a whereclause? Also this may be nitpicking but I think SQL is much easier to read if reserved words are in caps. SELECT forecast_FTEs.*, forecast_phases.*, budget_FTEs.*, bu...

@ckuhn203 privlidges? ;)
 
I no spell good @Phrancis.
3
 
@ckuhn203 Was a pure invention on my part! Find your quote funny! I immediately imagine someone making a script to invoke the devil! Made me laugh :P
 
4:23 PM
@Marc-Andre The Black Perl poem/Perl script comes close enough. While it doesn't use any single-letter variables, it does describe a black mass, and the Perl language is known for a plethora of obscure single-character variables, which doesn't aid readability.
 
@Ampt yea, "fixing"
 
monking @all!
 
What's up Mug!
 
Monking @Mat'sMug
 
Are we a bunch of backseat drivers asking "are we there yet?" all the time?
3
I'm starting to feel that we're kids in the backseat of a car going "Are we there yet?" over and over again. I hope the Community Managers does not think of us like that. — Simon André Forsberg 7 hours ago
Oh, kids, not backseat drivers ;)
 
4:26 PM
@amon Nice thing you got there!
 
Hopefully the awesome effort from @all since Nov '13 and the increase in new user activity plays in our favor, but TBH graduation or not, I still have a blast hanging out and reviewing code :)
 
@dagg "vba repository pattern" was a flawed search; nobody does that in vba ;)
 
@Mat'sMug apparently they don't, otherwise CR wouldn't be up there ;)
 
same with fizzbuzz on commodore :p
I think the best bet is the "hot network questions" link farm sidebar
4
 
4:29 PM
^^ TS ;)
 
@Phrancis I can't wait to see the graduation, but I'm becoming more minded on : We should do our best no matter what. I don't care anymore if it's next week or next year! I have a Stack Exchange where I can do what I like, read code and review it if I can find somehting!
3
 
^^ that
 
0
Q: Passing Row Index of TableViewCell [ custom] to another view controller

WhoamiI have been trying to achieve the below requirement. I could able to get it working. But want to make sure if i am doing in a right way ? 1) We have a table with customised Cell. [ say: firstViewController] 2) Customised Cell has a button , click event in this button, carries row index va...

 
It's just that graduation does make a nice "well done, guys - congrats!" from TPTB.
 
Thanks Santa!
 
4:34 PM
@Mat'sMug But we don't need it to have a lot of activity and fun! That's my point. It's a nice to have and when we will get it I'll be damn happy! (I was one of the most exited when we had the bug about the false graduation) But we're are still a community and we are already in good working state and we do a hell of a good job!
 
@Marc-Andre 100% correct :)
 
0
Q: Better way to implement screen wraparound?

KaoI'm implementing game with classical screen wraparound effect. It works very simple: if player goes out of screen, it reappears on the opposite side (Asteroids is a good example). This is my Java code: float x = getX(); float y = getY(); float screenW = screen.getWidth(); flo...

 
But we are losing some ground to the zombies
 
I don't the stats but I have the impression we get more and more askers, but the number of reviewers is not increasing at the same speed.
 
@Mat'sMug is there a way to flag old, obscure or lack-of-response-from-OP questions for deletion? I know of several that are highly unlikely to ever get answered
 
4:40 PM
@Phrancis A real good point there.
 
some of the best zombie killers have been on such questions though....
 
If this single line would fix the memory leak, then it's a miracle, TessBaseAPIDelete(api);
 
I think I should start sharing some CR stuff on FB
 
Don't blame us if you lose your FB friends.
4
 
@Marc-Andre rolfl has a SEDE query with ratio of questions to answers... there were increasingly more questions than answers for a long time but this year it pretty much leveled out
@Mat'sMug does Google even index FB? I never see FB stuff in search results...
 
4:47 PM
@Mat'sMug I don't think I've been on FB but once or twice since I found this chat room, a lot less drama here
(and lot fewer ads)
 
I'm like never on FB
 
Heh, I deleted my FB account (that I never used) months ago
Now I just have my old dummy account for if I get stuck working on some FB app
 
I'm still being a lurker on FB on highschool classmates mainly.
 
1
Q: Do we still need a database tag like [database-schema]?

JamalAs part of our mass meta-tag burnination, we're also considering database-schema. It also seems closely related to database-design, which has been burninated and blacklisted just recently. We already have a database tag, which is not up for burnination. I don't think we need very many database...

 
4:54 PM
2
Q: Do we still need a database tag like [database-schema]?

JamalAs part of our mass meta-tag burnination, we're also considering database-schema. It also seems closely related to database-design, which has been burninated and blacklisted just recently. We already have a database tag, which is not up for burnination. I don't think we need very many database...

 
@200_success Who needs FB friends when I have CRitters? :-)
5
@StackExchange Yeah, thanks.
 
@Mat'sMug I would probably use Twitter. I may be posting something on some facebook page of locals web programmers, maybe they will be interesting for them!
 
Welp, this is all I got before my program exited Java Result: -1073740940
 
Hey @Mat'sMug. Got a second?
 
yeah
hold on
 

« first day (447 days earlier)      last day (3586 days later) »