« first day (1284 days earlier)      last day (1569 days later) » 

1:55 AM
@Mgetz Ok, thank!
Silly question: what's the use of /HEAP?
If I have access to the 2gb of memory for my app, why do I need to specify a size for the heap?
 
user6461957
2:53 AM
What do you mean with having "access to the 2 GB of memory" for your app?
 
@d03 I work on a 32bit app, so "by default", I'm capped at 2gb.
(of ram)
 
user6461957
3:12 AM
Not 4 (2^32) GB?
I am guessing here, but maybe due to not having much RAM left in the first place? So you limit the heap so that it cannot grow beyond that making room for other processes?
 
@d03 Hmm, yes, it looks like it's 4g but you need to add a linker flag (stackoverflow.com/a/5686527) and as discussed here previously.
And for the /heap, yeah, maybe it's for smaller systems; but the thing is: I don't specify the value at the moment, and, of course, I bust the default 1mb size.
 
3:49 AM
According to this old article the /HEAP will be used for the initial allocation, and the heap will grow as the process needs memory (until it run out of addresses)...
 
user6461957
4:11 AM
So, to return a fixed size array in (ANSI) C, you do:

char (*ppm_get_pixel(...))[3];

?

That almost looks confusingly similar to function pointer declarations.
 
user6461957
Is there a mental cue for this perhaps akin to pointers (left-right rule)?:

int **x; // a pointer that points to a variable of type int pointer.
int **const x; // a constant pointer to a variable of type int pointer.
...
 
user6461957
4:28 AM
Correction: returning a pointer to a fixed size array. You can't apparently return fixed size arrays.
 
5:38 AM
@Vaillancourt /HEAP lets you specify the amount that will initially be committed (and optionally, reserved) for the heap. So you have 2 GB of address space, but initially only 1 MB of heap space allocated. As you use more than that, the system has to allocate more space for your process' heap. If you use /HEAP, you can specify that more will be allocated (or committed) at startup time, to save time adding it later.
 
 
3 hours later…
nwp
8:35 AM
@d03 C and C++ don't allow passing C arrays as parameters or returning them. Stuff them in a struct and it works fine (which is all that std::array is).
 
user6461957
@nwp I did this: `void ppm_get_pixel(ppm_t *ppm, size_t x, size_t y, unsigned char dest[3]);`

But structs would be also an option.

Do you have a better mental cue for constructs like this, i.e., returning a pointer to a char array of size 3?:

char (*ppm_get_pixel(...))[3];

I am having trouble with that syntax.

(Here's the project I am working on - public domain: https://github.com/d03/two-file-libs-ansic)
 
nwp
My mental cue is to use std::array. std::array<char, 3> *ppm_get_pixel(...); looks pretty straightforward. In C you can use a typedef to get the same effect, but it's annoying because you cant just use a template typedef` and need to type it out again for every combination of type and size.
If you are in a lesson of sorts and have to know this for a test then ... I'm sorry for you. cdecl.org can maybe help you a little bit.
 
9:30 AM
Quick question. I find that many mistakes can cause a program to die with SIGSEGV signal. SIGSEGV is so vague, how do you guys normally debug that error? For a big project, you can't just read all the source code...
 
@Rick use a debugger
 
nwp
You have a debugger that stops the program when the segfault happens and jumps to that position in the code. Then you look at the values of the variables to understand why that happened and go up the stack in case someone gave the function bad input until you find the error.
That mostly works, until you get things like memory corruption where the error happens in one place and the crash in another.
 
then it's time for valgrind or something like it
 
nwp
Sanitizers help there because they make the program crash immediately on corruption, not later when using the corrupted data.
 
@nwp How would you know where to set the breakpoint to stop the program if you don't know where it will crash?
 
nwp
9:36 AM
You don't set a breakpoint. You just let it run and the debugger automatically pauses the program when it segfaults.
Maybe your setup is borked and the debugger doesn't do what it's supposed to do.
 
Ah I see. I didn't know that functionality before..
Yes, it did pause.
Setting breakpoints and running step by step are the only things I am familiar with debug.
I just tried that on IDE and shell (gdb). Both works. Thank you guys. ;P
 
nwp
I have no clue how you lived without that.
 
= =
Well, I haven't done big projects with C or C++
So I just examine the code line by line again and again..?
I know how to use a debugger.. I just didn't know it would pause when it segfaults..
 
user6461957
10:06 AM
There's also ddd (for Linux). It is basically a graphical gdb it may help visualize some things.
There is also many more options for gdb... you can use p to check out values /x to examine memory... and you can also debug multi-threaded programs (which I am not so experienced in yet).

Here are some references that might help:
- https://www.cs.umd.edu/~srhuang/teaching/cmsc212/gdb-tutorial-handout.pdf
- https://sourceware.org/gdb/current/onlinedocs/gdb/Memory.html
- http://www.cs.toronto.edu/~krueger/csc209h/tut/gdb_tutorial.html
 
Oh thanks. I know ddd. Graphical gdb doesn't do much better I think. I use CLion to write demos and it's good enough, so as GDB.
Yes.. sensible to halt upon a segfault. I just didn't know it . Sorry for my stupidity QAQ.
I used to write python
 
user6461957
Nah, nothing to worry. :)

> I used to write python

Are you new to the "C family" (C, C++)?
 
Absolutely ;). C/C++, from begining to give up.
 
nwp
Python tends to use very different techniques. There you can mostly just look at the traceback without even needing a debugger and TDD is pretty easy and painless.
 
user6461957
10:21 AM
@Rick Don't get frustrated. I was also at that stage years ago with C...

These are some books I really like for C:

- The C Programming Language
- Expert C Programming
- C: A Reference Manual

And for C++:

C++ Primer 5e
Inside the C++ Object Model

(These are outdated but still good for me. The latter is rather for understanding some things.)

But there's also a book called C++ Crash Course by Josh Lospinoso and it has good reviews on Amazon and is probably more suited for beginners.
 
Yes and it's interesting that Python's traceback is "most recent call last" while in C it's the opposite. bt in GDB (most recent call recent?)
(most recent call first?) *
 
 
2 hours later…
12:38 PM
To follow up on discussion the other day: if one wishes to have a `const` variable but needs to change its value once, the follow pattern can be used
int xtmp = userInput();
if(xtmp % 2 != ){ xtmp--;}
const auto x = xtmp;
Does this have any affect on speed? IIRC if a variable is declared as const the compiler swaps in the value. Is this still the case if the value is not known until run time (or not easily deduced)?
 
it's not going to be worse, especially if you std::move (for non-POD types)
 
12:51 PM
is it going to be better?
 
maybe, maybe not, depends on how smart the compiler is
 
I wouldn't count on const giving you much in the way of performance. It's a lot more relevant to reduce and prevent bugs
 
 
2 hours later…
3:05 PM
@JerryCoffin Ok, thanks! So given I'll use everything, I should just reserve 4gb.. :P
 
3:26 PM
or you can be charitable and actually see how much you require
 
@ratchetfreak Yeah; I kindof crash (bad_alloc) with 2gb...
 
then check your allocations and see if you really need all of them to stay alive
it's very easy to have 2 or 3 unintentional copies of large data structures floating around
your first reflex to getting OOMed should be to reduce your memory usage, not increasing the limit (which is only a temp fix if you don't know what is grabbing all that memory)
 
@ratchetfreak It's quite the opposite, actually, the memory is very fragmented (see the image here).
We load 3d models and upload the textures to VRAM.
This process fragments the memory, to a point I get bad allocs when I try to load a 64mb texture (e.g.)
The ideal strategy here would be for us to load the images ourselves in a specific location (and manage the memory ourselves). The ideal ideal strategy would be to have complete control over where those models are stored, but that would involve hacking and slashing a bit too much into our 3rd party rendering engine.
We're kind of constrained by time (and thus by risk management). Increasing the memory used is a quick fix, for now, but will come and bite us in the ass at some point.
 
3:58 PM
@Vaillancourt which engine? If you don't mind me asking
because you should just be able to load them all into an arena allocator
 
@Mgetz OpenSceneGraph
I'd be happy if the engine could handle such memory allocation, but I haven't seen anything about it.
 
4:30 PM
Game engines can, like UE4
but they usually expect 64bit these days and use memory tricks for speed by keeping the cache hot and focused
 
OpenSceneGraph was a little antiquated last time I looked at it, you might have a better chance with other tools
 
@Mgetz Yeah; I wish we had the kind of resources those teams have :/
@PeterT Oh, err, yeah; the guy who maintains it will no longer do development on it. We'll have to decide if we go to a Vulkan scene graph engine or another OpenGL rendering engine. Thing is, we have been using that for years, so it's not an easy swap.
 
@Vaillancourt Honestly? I'd consider just testing how far UE4 or similar could get you
 
@Mgetz I wouldn't really mind using that, but I'm quite certain that this would not pass through the hierarchy.
 
@Vaillancourt licensing? or time?
or both?
 
4:44 PM
@Mgetz something like "I need to be able to compile and release this app again in ten years from now, with the compiler and OS available then". Long term maintenance of our apps.
 
unless you're on linux... that's completely insane
an even on windows that's inane
 
unreal is source available so you can have a copy of the source right next to that project
 
We're on Windows. We have issues with some of our apps that we need to keep VS 2010 (or 13) around because they won't compile with newer versions.
@ratchetfreak I wasn't sure about this.
I'll poke Unreal around and see :)
 
building current UE4 with VS2010 might not be fun
or possible
 
Most likely "not possible" :P
 
4:53 PM
they don't (officially) support it so you are on your own for trying to get vs2013 to compile it
 
@Vaillancourt so you have crap code ;p
and management won't let you fix it
 
@Mgetz We use a specific 3rd party library for which we only have the binaries, as I understand (the scene graph we used before OpenSceneGraph). (this does not exclude the fact that we most likely have some crap code somewhere :P)
 
5:11 PM
@Vaillancourt honestly? I'd ship a separate converter tool to allow people to convert to latest
remove that crap
 
@Mgetz We can't just do that, we need to rebuild the app with the newer library. It's not a drop-in replacement.
 
wut
 
@Mgetz You mean, convert the binaries?
 
no convert the customer files that use the old binaries
 
at worst you can ship an executable that will take in the old format in stdin and spit out the new format in stdout
then you can decouple the old binary from your current program
 
5:17 PM
I mean the built library binaries. It's not about the file format
 
doesn't even have to be the new format, but a format that is usable by your new program
 
It's the rendering engine lib
 
yeah you're screwed then, I'd find a new one you can compile from source
 
Yeah, that's what we have now (openscenegraph), but we can't get rid of those old apps because they're still in our catalogue, but they don't sell enough so that there is no incentive to make a "version 2"...
 
then remove them?
and don't hold your main codebase back?
 
5:21 PM
We can't remove them because we manage to sell some "sometimes" :P But I guess at some point we'll have a hard time releasing them so they cooperate with Windows nicely. Fortunately, we have a separate build environment set up for those, so we can still do "modern" stuff with the apps for which we have all the source code.
 
that's the biggest heap of garbage I've heard in ages. Either it's cost effective to maintain them or it's not
if they aren't keeping track of that time then they are potentially losing a LOT of money
 
@Mgetz Fortunately, I'm not the one who maintain those apps, with all the infrastructure required for them. If management feels like it's worth it, good for them, and if they enjoy keeping those around because "we can" then good for them too ;P
 
not if it's costing them money. That could cost you your job!
products need to pay their own way
 
@Mgetz I'll say "their loss" to that ;P I've kind of stopped being worried by management decisions here; that's not how I'd manage things, but that's not my company, so there is little I can do about some aspects of it.
 
 
2 hours later…
7:01 PM
woooa the memory profiler in VS!
 
7:50 PM
And it looks like /LARGEADDRESSAWARE patched the issue I had! thanks all for your help!
 
8:10 PM
@ratchetfreak Looks like you were right here. Looks cleaner to not reserve to not reserve everything. Not sure about the speed gains though.
Startup speed is not significantly different.
 
8:36 PM
@Vaillancourt no it probably created issues you didn't know you had that would have affected 64bit
test extensively
 
@Mgetz What do you mean? What kind of issues do you have in mind? (I'm currently having an issue in 64bit that I don't have in 32bit, even with the /largeaddressaware.)
And yeah, thanks for the tip, we'll need to test :)
 
8:52 PM
@Vaillancourt most likely? People using pointers to pass info that's not a pointer
or passing a pointer in an int
 
@Mgetz Doesn't look like our style, but maybe some libs we use might have that buried deep down.. :/
 
9:14 PM
Its me again... quick question... Why cant i pass a "int &&rVal = 10;" to a method "foo(int &&rVal);" ?
*directly without using move
 

« first day (1284 days earlier)      last day (1569 days later) »