« first day (714 days earlier)      last day (4233 days later) » 

12:08 AM
@Xeo Not a problem. I can't remember my grandpa ever reading to me -- and if anybody had called in friendly, I'm pretty sure he'd have straightened them out on that misconception in a hurry! :-)
 
12:40 AM
I wonder which Vim commands I should bind to the side buttons this mouse.
 
1:33 AM
posted on September 29, 2012 by Raman Sharma

Background If you have shipped software built using Visual C++, you probably have had to think about deploying C++ Runtime DLLs.  If your binaries dynamically link to the C++ Libraries, then your desktop apps probably deploy C++ Runtime using VCRedist, merge modules or by copying C++ Runtime DLLs alongside your own binaries.  In this blog post, we are going to look at how this p

 
I wanna develop a really basic path tracer (emphasis on basic). For this I was thinking about having a C++ dll running under a C# (WPF) interface. Any good places I can look for insight on this sort of architecture? :)
 
 
1 hour later…
2:45 AM
The room is always dead on Friday nights...
 
@Mysticial It is. You'd think all the usual habitues were socialites or something (or in Europe, where anybody not out drinking is long-since in bed by now).
 
What about if you use a std::list? Will that circumvent the invalid address problem if you only use list.push_back() calls to add items? (and you don't remove the item that oneNumber points to? — bobobobo 1 min ago
Adding/removing elements to std::list should not invalidate pointers right?
 
@Mysticial for adding that's obvious, but for removing it depends
 
@Cheersandhth.-Alf In what situation would it break on removing an element? Or does the standard just not guarantee?
 
i am not at all sure whether pointer to an element is invalidated if that element is spliced from one list to another
 
2:57 AM
@Mysticial At least if memory serves, unless you remove the item the pointer points at, they should remain valid.
 
I heard about a Win-only socket API that can handle more-then-usual bandwith. Can anyone let me know what they are called?
 
but say you have a list of integers which includes the integer 7. when you remove it, it's gone. any pointer or ref or iterator to it is now invalid.
 
@Cheersandhth.-Alf As long as the two use the same allocator, I'm pretty sure it should remain valid. If they use different allocators, I'm pretty sure it has to invalidate it (basically has to allocate a node with the target allocator, copy then delete the old node).
 
Like say, for a large amount of connections and traffic
 
ah
you're actually awake
i'm just sort of peeking my head up
 
3:00 AM
anyone?
 
@Cheersandhth.-Alf It's semi-early evening for me. It must be, what, 3 or 4 AM or something insane for you?
 
yep
i think as a general rule, cookbok recipe answers score higher than teach-how-to-fish answers
 
@user1220811 Based on that (nearly nonexistent) data, I can't even begin to guess. My immediate reaction is that there is no such thing -- I've pretty much saturated a 1 Gb/s connection with a perfectly ordinary socket.
 
i just saw two answers right now and the cookbook one scored higher than the good one
 
@JerryCoffin ty for your help but I can't provide much more info :( I will sweep the internet somemore. I'm sure it exists. I saw the MSDN online docs for it. Hmm I was hoping someone could make my search easier but ty for your comment
 
3:04 AM
@Cheersandhth.-Alf I'd tend to agree. A lot of people are in the "just gimme the codez" mode, so if you try to educate instead, you're obviously just too lazy to do your job (no matter how much extra work working at educating might have really been).
 
I can't wait to finish some of my projects to begin work on my 'droid. Seems like a little gingerbread candystore
 
@user1220811 Too bad all the candy has that extra-bitter Java flavor.
 
hmm I guess you are one of the write once, debug everywhere croud
It does lack STL but JavaFX seems promising
Eh, I will just wrap my winsock functions in a neat class so I can just modify the class if I decide to change the API later
 
3:20 AM
@user1220811 Only when/if I'm stuck using crap Java. In C++ it's been so long since I used a debugger I can barely remember how.
 
@JerryCoffin Not mentioning the swarms of nasty bugs.
 
I do enjoy Cpp
 
You should have a look at Boost PP then.
 
Boost is nice I almost used their SSL libraries but OpenSSL won
 
@user1220811 Does Boost have any SSL other than ASIO's OpenSSL wrapper?
 
3:23 AM
@JerryCoffin I think it was Boost::ASIO
 
@StackedCrooked Yeah -- even the most ambitious would have a hard time with the "That's not a bug, it's a feature" line.
@user1220811 Hmm...and you used raw OpenSSL by preference? How...odd.
 
@JerryCoffin It made more sense to me... somehow
I found it funny, apperently, some parking meters use Java
 
3:40 AM
@user1220811 Not sure about parking meters themselves, but there's no question that the smart cards used in some parking meters do, but it's the "micro" edition of Java, which, despite the name, is not really all that close to normal Java.
 
@JerryCoffin Hmm... I haven't heard of Micro but I have heard of JME
@JerryCoffin (M)obile
 
I may be a little late on this technology I just bought a book on it years ago when I had the chance
You know (something I noticed) in the movie Iron Man 2, when Tony Stark was going to his car at the beginning, He exchanges words with an Oracle guy
Oracle is huge
 
4:03 AM
@user1220811 Oracle is definitely a large company, no room for question about that.
@user1220811 "an Oracle guy" being Larry Ellison, President, CEO and general high Poobah of Oracle, unless I'm rather mistaken.
 
Poobah?
Grand Poobah is a term derived from the name of the haughty character Pooh-Bah in Gilbert and Sullivan's The Mikado (1885). In this comic opera, Pooh-Bah holds numerous exalted offices, including "First Lord of the Treasury, Lord Chief Justice, Commander-in-Chief, Lord High Admiral... Archbishop of Titipu, and Lord Mayor" and Lord High Everything Else. The name has come to be used as a mocking title for someone self-important or high-ranking and who either exhibits an inflated self-regard or who has limited authority while taking impressive titles. The formal term for the practice of ho...
TIL: Poobah
 
wtf?
 
Any OpenGL developers here?
 
@BenjaminDangerJohnson I've written some programs using OpenGL, but it's been long enough that I can't claim any high level of expertise with it at the moment.
@Cheersandhth.-Alf Oops -- should have said "grand high Poobah" rather than "general ...". The obvious difference being that at Oracle, I'm pretty sure his word really is pretty much law. The "inflated self regard" seems to fit pretty well though...
 
ah, well, I appreciate your honesty Jerry, but most likely you can't help me
the language changes too dam fast
but for shits and giggles I guess I can post the question I've got
 
4:15 AM
I don't think we have any regulars here who use OpenGL.
 
Yeah I realize that, but no one is ever in the OpenGL room
1
Q: VBO dissapearing, bad Matrix?

Benjamin Danger JohnsonI'm not sure why but my VBO is disappearing after one frame (initial frame shows it at the origin improperly angled) Below is the code for my matrix class, the draw method, and the vertex shader. Matrix::Matrix() { for (int i = 0; i < 16; i++) { values[i] = 0; } } Matrix Mat...

just figuered I would give this a shot
it's way more difficult than I would like to get help on these questions.
 
Give it more than 5 hours. I'd say at least a few days. Not everybody camps the site 24/7.
 
haha, fair enough
I guess I am too impatient
I just figuer it's easier to check the chat
 
Especially on Friday nights. :)
 
good point
To the ladies!
away
 
4:20 AM
@BenjaminDangerJohnson Yeah, I glanced at it earlier. I didn't look at it in a lot of detail though -- my immediate reaction (quite possibly mistaken though) was that it was more likely a problem in the matrix code than the OpenGL code itself.
 
5:04 AM
question... to end strings should I use std::endl; or "string\n\r"?
 
Define "end string".
You mean a new line?
 
String literals and std::string are agnostic in that respect. Put in the characters you need.
 
like cout << "String" << endl; or cout << "String\n\r";
 
The \r isn't necessary.
 
std::endl has the semantics of passing in '\n' (or a wide version) and calling flush.
 
5:07 AM
which is the best to use in a console application
 
Do note that std::endl isn't related to string literals or strings.
 
Otherwise, they're equivalent except for maybe a buffer flush.
 
so std::endl; it is
 
Why not just "String\n"?
 
I'm not sure whether std::endl and/or printing a \n will force a buffer flush. But you probably don't have to worry about that.
 
5:09 AM
is a buffer flush a good programming thing?
 
@user1220811 If you don't know what it is, then you don't have to worry about i.
 
I heard buffer flushes are good things for sockets and I happen to be using them
@Mysticial does that matter? at all?
 
Not for a console application that does e.g. simple line-based I/O.
 
@user1220811 Yes, there are some cases where buffering makes a difference.
The most common one I see on SO are those involving fork() and those that ask why a program segfaults before something is printed.
 
well fork is a 'nix thing... would that cause trouble multitasking?
for a Win application?
 
5:16 AM
If you have multiple threads writing to the same console, the buffering can make a difference.
 
@Mysticial sorry for trying your patiance but one more question... would std::endl; really eat up enough CPU power to discourage me from using it?
 
lol
 
lol
If you're printing stuff out, that last thing you need to worry about is performance.
 
@Mysticial I'm trying to produce a performance server application so I need maximum resources
 
You shouldn't be printing stuff out if this is a performance server.
 
5:20 AM
Just the basics
 
Hola :-)
 
hmm, good point
@jweyrich hola
 
hiya
 
@user1220811 At least if you're writing to a normal file, yes, it can reduce performance dramatically.
28
A: mixing cout and printf for faster output

Jerry CoffinThe direct answer is that yes, that's okay. A lot of people have thrown around various ideas of how to improve speed, but there seems to be quite a bit of disagreement over which is most effective. I decided to write a quick test program to get at least some idea of which techniques did what. #...

If you're talking about writing to the screen, then endl probably won't make enough difference to notice. I've never tried it with a socket, so I can't comment intelligently on that.
 
@JerryCoffin ty I will read that
I thought it was more of a fast and safe rule
I didn't really look into it
 
5:36 AM
You are on the Unanswered tab.
There are no unanswered questions at the moment.
Perhaps you'd like to select a different tab?
 
@user1220811 Yes and no -- flushing the buffer gains safety to the degree that if your program crashes, data that's still left in the buffer is typically just lost. If you flush it, there's a better chance (but still no guarantee) of its getting to the destination.
 
@JerryCoffin Cool. You killed in that topic.
I thought there would be a bit of a stir about it. Yet, I thought of going to the chat first...
 
@user1220811 Glad it was helpful.
 
5:56 AM
So apparently my HDD wasn't showing on the defragmenter because one file in it had some free memory that was marked allocated...
 
6:19 AM
How to rob a bank and avoid being considered robber. — Mehper C. Palavuzlar May 22 '10 at 20:59
 
6:50 AM
just be anonymous
 
7:39 AM
@chris People still defrag these days? Isn't that more or less a waste of time?
 
@FredOverflow That's true for the most part. There are some shitily written programs that don't pre-allocate files when they make them. Those will fill up fragmented spaces.
If I created a file using fopen() and wrote a ton of data to do it, it will fragment if the free spaces are fragmented.
 
But is a fragmented HD actually noticeably slower?
I thought modern file systems like NTFS don't fragment so much, no matter how stupid the application code?
 
@FredOverflow I've definitely noticed it when I was writing my Pi program.
 
Is fragmentation still relevant on SSDs?
 
It outputs large text files which get fragmented. Then when I do a hash over them to verify them, it's noticeably slower if it's heavily fragmented.
@FredOverflow Much less so. And you wouldn't want to defrag an SSD anyway.
 
7:43 AM
I like to believe that multiple partitions are a good measure against fragmentation of large files. I simply put all of my large files on a dedicated partition, and I just live with the fact that my system partition will have some fragmentation.
 
The only other situation where a drive will get fragmented is when it's almost filled up.
But that's never a problem for me since my boot drives are almost always more than half empty.
 
Are you talking about SSDs now?
 
No, still HDs.
 
Interesting, so HDs will prefer never-before-used blocks to recently-deleted blocks or something?
 
A lot of defrag programs do more than just defrag. They also move commonly used files to the front and the rarely used ones to the back.
The "front" of a drive (the lower physical addresses) are usually mapped to the outer edges of the platters. They are fastest because their tangential velocity with respect to the head is highest.
@FredOverflow Well, if you pre-allocate a large file, the OS will try to find the first free block of suitable size - so it doesn't get fragmented.
So if the lower addresses have a lot of fragmented free space (as is the case for an OS partition), a large file will naturally be pushed further back where there are large contiguous blocks of free memory.
From what I've seen from my days of testing that Pi program, filling up a drive to where the inner-edges of the platter are needed is a huge performance hit.
Fragmentation aside, the bandwidth is cut usually by more than a factor of two.
And random access latencies are also about doubled because the head needs to swipe across the entire platter instead of just the outer-most parts.
 
7:53 AM
@Mysticial How do you preallocate in C, for example?
 
@FredOverflow You can't. Not portably.
 
In Linux, you can just write a byte at a large offset and it will preallocate everything up to that point.
In Windows, it's a two-step process.
SetEndOfFile() to set the size of the file. Then SetFileValidData() to actually force the OS to allocate it.
The latter one requires elevated privileges.
If you try the approach that works in Linux in Windows, the OS will zero all the data from the start of the file to where you wrote the byte.
For the same security reasons covered in my answer here about malloc() zeroing memory.
 
8:12 AM
Is implementing your own version of malloc something that's on your curiosity TODO list? :)
I wrote my own version of malloc a couple of years ago, but of course it was a toy implementation (used a static buffer under the hood, no requests to the OS), and of course its performance was terrible.
 
@FredOverflow I did that 3 years ago. The very first publicly released version of my pi program already uses it.
 
Did it have any advantage over the real malloc?
 
I wouldn't say that it's efficient, at least not for "normal" application usage.
 
So why did you write it? Curiosity?
 
It had two properties that I needed:
1. No zero-filling.
2. Deterministic.
 
8:14 AM
By the way, why does malloc take only one argument, but calloc takes two arguments?
In what sense was it deterministic?
 
@FredOverflow The original reason was that my compiler didn't have a thread-safe malloc(). So I had to write my own.
 
The no-zero-filling was an advantage that I later discovered.
 
To be honest, I wouldn't know if gcc's malloc is thread-safe or not...
 
The determinism made it nice to debug.
 
8:16 AM
Do you mean that every run of the program always allocated the same chunks?
 
yes
When a thread forks, the heap splits into separate sections. That way I can preserve determinism even through multi-threading.
 
How did you make it thread-safe? Old school locking, or lock-free data structures and algorithms?
 
Only one thread is allowed on a heap at a time. But a heap can be forked into two child threads. Each of the child thread is only allowed to touch its own portion of the heap.
 
And how much overhead did an allocation have? I think mine was two pointers per allocation, but it's been too long...
 
It's quite high actually. O(N) to the number of live allocations. But the program never has more than O(log(N)) live allocations. And the basecases are heavily optimized with stack memory to avoid repeated small allocations.
My current unreleased version is optimized even further so that there is never more than O(1) live allocations at a time.
So basically, my memory allocator is specialized for the program. And it has too many restrictions to be a drop-in-replacement for malloc().
@FredOverflow Oh, no locking required. Since everything is done in a fork/join data-flow.
 
Ell
8:23 AM
Morning all
 
@ScottW down? Did something get deleted?
@Ell evening
@ScottW There's a checkbox at the bottom of your reptab.
 
Ell
I had an idea. You should be able to have multiple facebook profile pictures so when you change your mood to angry, a picture of you being angry shows
 
I found five questions on SO regarding the implementation of malloc and free. I have voted to close four of them. Anybody wanna join me? :)
15
Q: How do free and malloc work in C?

user238082I'm trying to figure out what would happened if I try to free a pointer "from the middle" for example, look at the following code: char *ptr = (char*)malloc(10*sizeof(char)); for (char i=0 ; i<10 ; ++i) { ptr[i] = i+10; } ++ptr; ++ptr; ++ptr; ++ptr; free(ptr); I get a crash with an Unhand...

10
Q: How are malloc and free implemented?

SquallHello I want to implement my own dynamic memory management system in order to add new features that help to manage memory in C++. I use Windows (XP) and Linux (Ubuntu). What is needed to implement functions like 'malloc' and 'free'? I think that I have to use lowest level system calls. For Wind...

11
Q: How is malloc() implemented internally?

bodacydoCan anyone explain how malloc() works internally? I have sometimes done strace program and I see a lot of sbrk system calls, doing man sbrk talks about it being used in malloc() but not much more. I'd really like to learn how malloc() works. Thanks, Boda Cydo.

 
@Ell Make a to meta.facebook.com. :P
 
1
Q: How are malloc and free implemented in C?

BruceI read somewhere that calling free twice using the same pointer argument causes undefined behavior. So how does free know how much memory it has to free? Does the heap always allocate contiguous memory when we call malloc/calloc/realloc? Please provide links to relevant articles/posts/blogs etc.

On the contrary, as a C programmer, you have to be very aware of memory management, because you're doing it yourself as soon as you touch the heap.
lol, I just caught myself trying to upvote one of my own answers :) That's at least the second time that's happened to me.
 
8:31 AM
Most of us like to forget about memory and worry about the code.
 
Sure, but some poor soul has to implement all the nice virtual machines and stuff :)
I have been listening to a couple of interviews with Patrick Dussud lately (the man behind the CLR GC). In one of them he said "Without a Garbage Collector, you're in a heap of trouble" :)
 
I had to micro-manage memory in that pi program. There were too many gotchas that can happen if you rely completely on a malloc()-like interface and expect it to behave correctly when you're maxing out resources.
 
@MooingDuck How long have you known her? (Or him? Or duck? :)
The IAU ban came after the 'redefinition of 'planet' to include the IAU president's mom' incident.
2
 
@Mysticial Well that's one way od looking at it. OTOH, for many apps, data design, and how it's placed, and how you access it, is very important. If you get the data right, the code just falls out. NOt even mentioning embedded RAM.
 
Ell
The memory is so tender, code just falls off the bone and melts in your mouth
 
8:38 AM
by the way
why does alignof exist in C++11 when you have std::alignment_of?
 
@ScottW Yeah... pretty much. You won't believe how many times I've had to break through abstraction layers to get that control that I needed.
 
@Ell Apropos, there are two new episodes of Bones, nice :)
 
@DeadMG IIRC I remember seeing an SO question about it. But it's been a while.
 
@Mysticial Moan... my boot drive is about 2/3 full and I'm getting increasing numbers of pauses, (256G SSD). Not sure whether to clean up all the shit on it, defrag, backup and restore or migrate to a 512:((
 
@MartinJames Does your mainboard have AHCI or whatever it's called?
 
8:42 AM
@ScottW To give you an idea, one of the most annoying things that I had to take control was the entire I/O interface. I couldn't use the normal I/O functions because the OS's buffering algorithms would puke under my work load. So I had to implement everything through DMA and handle all the buffering and cluster alignment myself.
 
@FredOverflow Yes, but the OS is Vista, so drivers may, (may?), be crappy.
 
oh, C compatibility, I think
 
@MartinJames Funny, just yesterday I plowed over my Vista partition. Maybe you should do the same? ;)
Is it possible to really delete stuff from an SSD?
 
@FredOverflow You write to the entire surface multiple times.
 
So dd if=/dev/zero of=/dev/sda will wipe everything out?
Is the "multiple times" part specific for SSDs?
 
8:45 AM
what happens if you modulo something by 1?
 
@FredOverflow Yeah - I forgot to list that option. Our 'TV server' downstairs is W7-64 and, despite having less RAM and a slower, (slightly), AMD with fewer cores, it is noticeably faster than my development box.
 
@DeadMG The result is 0, because everything can be divided by 1?
 
yeah, I figured
just wanted to check
realized that my memory arena code didn't properly deal with requests for over-aligned objects like SSE
 
@MartinJames Faster doing what? If you wait for the hard drive, as I suspect is the case for a TV server, it doesn't really matter that much how fast the CPU is :)
 
@FredOverflow I guss so. The NAND flash cannot be overwritten - it has to be erased first.
 
8:50 AM
this correct?
 
@FredOverflow It has an SSD as well for the boot disk, with spinners to actually store the miserable daytime-TV crap that Anne keeps filling them with. It's faster booting, it's faster browsing, (it's on the same network with same net connection as my development PC), and is just, well 'faster':(
 
@DeadMG lol, for a moment I misread auto ptr as auto_ptr :)
 
@FredOverflow lol, nope :P
 
From the names allocate_for and allocate_next I am inferring that you are implementing something to do with pools?
 
@FredOverflow It's my memory arena code.
allocate_next allocates another chunk from the CRT heap and puts the object in there.
 
8:54 AM
Is alignment required to be a power of two? Then you could get rid of the potentially expensive % and replace it with &(alignment-1).
 
@Ell Err no, my code is not that tasty. It's 'Tesco Value code' - keeps you alive but it would be nice to get something better:)
 
@DeadMG The purpose of a memory arena is that it can be freed at once, as opposed to individual frees, right? What do you need that for, linked list nodes?
 
@FredOverflow So that it can grow.
the cost of the list is quite minimal as long as you have a suitably large buffer_size.
 
Oh, so you're reimplementing realloc? :)
 
no
if you have a pool, then what are you gonna do when it gets full? cry in a corner? :P
 
8:56 AM
Do you have a specific use case for your memory arenas, or is this generic Wide runtime code?
 
it's generic runtime code
I've used it in a few places
the point of the pool is to amortize allocations- and paying one new every 10MB or whatever you'd like really isn't a big deal at all
 
Where does alignment_increase come from, or should that be alignment_adjustment?
@DeadMG Right, but then you can't free individual objects, can you?
 
@FredOverflow Nope, you can't. But that's fine.
the use case of a pool is when the efficiency of freeing in very large amounts is more important than the ability to free individually
 
right
 
well, you never decrease the used memory to account for alignment :P
 
9:00 AM
How about one pool per requested alignment? Wouldn't that waste less space?
 
well, then I'd have to allocate a whole pool if you allocate one single SSE type
 
You could start small and grow the pools exponentially, then it wouldn't matter.
 
currently, each pool is of fixed size
 
@DeadMG Usually, when a pool gets full, (I think of it as empty), the caller blocks until something returns items to the pool. This either works fine or deadlocks. I've had both <g>
 
well, by "fixed" I mean "invariant", you can pass a template parameter to customize the size
 
9:03 AM
@DeadMG When you do the allocate_next or whatever that was called, can't you just request twice as much for that?
 
@FredOverflow I currently simply allocate a struct with char buffer[buffer_size] in it.
besides, if you need to keep expanding the block size, you're using the pool wrong
I think
I guess that there's no reason why buffer_size should be a constexpr
 
9:19 AM
0
Q: Why SO is a disservice to humanity

stackmonsterNo one is going to like this. The Internet(s) have not changed a fundamental corollary of imparting wisdom on the masses. Instead the Internet created in place of time worn practices for hand me down knowledge, a tower of babble of search. Knowledge in the sense that its represented on the Inte...

 
ho
hi*
 
@Mysticial tl;dr? (or: is it worth reading or just random rant?)
 
does anyone here have experience with btstack?
 
@NikiC I'm still reading it. But the title is just asking for it.
 
9:23 AM
@NikiC it's an apple fan boy who just wants to cry a bit
probably because his iphone 5 sucks donkey balls
 
@NikiC tl;dr is "I'm an elitist jerk and you should have to be a good programmer before you can be taught programming"
 
@DeadMG Thought so. Will not read then, to preserve my happy morning attitude :)
 
I have tried so hard , but still I couldn't set up the libjpeg in Dev C++ or any other compiler and/or environment
 
@bamboon There's an app for that?
 
begging -> counterproductive.
 
9:29 AM
Refering to me?
 
wait, there were more messages there
how did you bin them without the bin message?
 
@MartinJames sorry, I don't get what you mean right now?
 
Anyone?
 
@NikiC Well, I could have binned the third too, and I still might, but we'll see.
 
Ell
9:38 AM
Agh girls are too much effort
 
@DeadMG Oh... yeah I see a reversal badge coming your way. :)
 
OH, BTW, thanks to whoever it was that linked that Obsidian Shell-Elysia download. I listened to the whole album last night and, even though I could not understand the lyrics, I did enjoy it.
 
@MartinJames lnk?
 
9:56 AM
@jonsca Nah. After re-reading the question, I think I have a clearer picture of what's going on. The OP went through a life of suck (where information was expensive). And now he's jealous that, in the current era, information is free. So he basically wants SO to shutdown because it's providing so much free information. All that stuff about garbage is just an excuse. It's a psychological thing. When you don't like something, you will subconsciously try to find a reason to justify it. — Mysticial 2 mins ago
 

« first day (714 days earlier)      last day (4233 days later) »