Lost memory? Is it C++, xCode, std or some JUCE library?


#1

Hello, sorry for strange subject but I am not sure how to say that.
I try to debug some value, but I have strange behaviour which I don’t understand.
When I use std::cout << someValue << std::endl; in some way someValue lost it’s value. Is it normal behaviour? Please find my screen shots:

Without std::cout:


And with std::cout:

And now even if I use “view memory of fff” there is nothing. It’s empty. Is it normal behaviour? What’s wrong here?


#2

And the second question is: why wZoom.getMaxValue() gives me 22049.999999 instead 22050?

My wZoom range is from 0.999999 to 22050.0, and of course max value thumb is moved to max.


#3

It‘s very close to 22050 :slight_smile: that‘s probably due to the good but limited precision of floating point numbers. Floating points might not be able to represent 22050.0 so the closest possible value was chosen: 22049.999999 which is basically 22050 :wink: the step to the next higher value (22050.something) is bigger then the step down to 22049.9999 so the error is smaller with that one


#4

OK, but as you can see I use double there.
And As far as I know Slider.getMaxValue() and Slider.getMaximum() return double.


#5

Double is also floating point but with double precision


#6

OK, it’s to complicated for me probably :slight_smile:
But what about my first question, about loosing value?


#7

I think that‘s just a peculiarity of your debugger, the value is not really lost, just the display is strange. You will still be able to access it in your code (hopefully :smiley:). But maybe someone else has a better explanation for it


#8

Yes I still have access to fff so probably you are right the problem is debugger


#9

Is this a debug or release build?


#10

Debug


#11

I think Xcode sometimes does this if it doesn’t have direct access to the value. This could be because the variable is in a register than a memory address…

If you pause the debugger and type p fff, does it printed the the console? (There’s a good chance this will fail as well if it can’t be shown in the variables list though).


#12

OK, thank you , but sorry I am not good in xCode debugger, could you explain exactly where to type p fff?


#13

in the lower right of the Xcode is the output window, where you will see (lldb) when execution is paused:

thanks @dave96 I did not know you could do that when paused!


#14

heh, that works, thanks :slight_smile: