large column vectors crash in matlab crash win 7 Aero - windows

I'm using matlab R2014b 64 bit. I have a problem with large column or row vectors in matlab, when they get to be the size of about 100K samples or larger. The software behaves just fine with them, but it's actually the tool-tip that is the problem.
If I hover over the variable, it seems like Aero or DWM crashes under windows 7. I get sent to a black screen and then it recovers. After it comes back a bunch of my chrome windows are missing their title bars. I guess it's possible this isn't an Aero problem at all? Maybe just a chrome thing? I hope this is the right stack exchange to be asking this question, thanks.
This is what happens:
Edit:
Save the following code into a .m to reproduced the bug. Put a breakpoint on the disp() and run the code. Hover over the variables to generate the crashing tooltip:
ok = ones(1,500).*1j;
ok2 = ones(500,1);
notok = ones(500,1).*1j;
disp('done')
As seen here, the crash is limited to large complex row formatted variables

1) Run MATLAB as administrator
2) Execute the command edit datatipinfo in the MATLAB command prompt
3) On line 48 of the code (might be different in another MATLAB version) which should be val = val(1:500);, please reduce the value from 500 to lower number.
4) On line 37 which should be tooBig = max(s) > 500 || numel(val) > 500;, please reduce the value to the same number as in step 3
You may have to play around with reducing the value to find something that will work in your case.
from
https://cn.mathworks.com/matlabcentral/answers/43170-viewing-variables-in-debug-window-disables-aero-interface

Related

Use cuda to get screenshot of visible application

I am owner of a Nvidia GTX 1060. I know that with Windows it is not possible to directly access the video memory of the graphics card. But I read somewhere on an email list that it is possible to fetch the pixels that are displayed right now on the monitor with use of the CUDA API. Unfortunately I found no code example for this.
What I want is something like an bitmap-like array containing the rgb values of the pixels
arr[0] = 255 // red
arr[1] = 255 // green
arr[2] = 0 // blue
arr[3] = 0 // alpha
arr[4] = 255
...
Can someone please show me an example how to do it with CUDA?
I know there is a way using DirectX or openGL. I already tried it out but it is either too complex or too slow and won't work with fullscreen and windowed applications at the same time.
What you are describing is not only impossible, it may be even seen as a security flaw. In general, one application should not be able to retrieve the shown window of another application without some kind of consent and control from the operating system.
I remember reading about exactly that kind of a flaw few years ago, but I couldn't find the article anymore. However, there are many other articles discussing similar issues. For example in:
http://ece.neu.edu/groups/nucar/NUCARTALKS/snp14-gpusteal.pdf
they discuss GPU vulnerabilities allowing a malicious program to partially reconstruct a webpage shown in Chromium.

Images in datagridview once more time

I need your advice on a rather simple question - I'd like to draw an image in datagridview cell.
The problem is that the number of rows can be rather big: up to 100 000 of rows, sometimes more than that.
I tried using CellFormating but in this case the grid is blinking. I tried to set DoubleBuffered = true but it got only worse - the window hung and CPU usage was showing 100%. Other controls stopped drawing itself. Moreover it did not help blinking too much (even on several rows).
So I tried to use source DataTable and added a column. Than I filled it with images. But it was a fail: app memory grew very fast on a big datatable and it just crashed.
Also I tried using DataSourceChanged event and settings images like row[cell].Value = . It fires but grid works strange: sometimes it shows images, sometimes it does not. I read that you must set underlying data to make this working but it caused memory problems as I wrote.
I changed image to text so far but certainly I'd like to have moe user-friendly UI.
What can I do in this case? Probably I should give up images or change display logic at all? I.e. use virtual mode. I tried to use it long ago but I had some difficulties so I just skipped this way and my grid is working in non-virtual mode.
Ok, I eventually used CellFormatting event. It looks like blinking has gone away without my help. Images are looking fine.

Matlab GUI Compatibility Between Mac and Windows (Display)

For some time now, I've been working on a series of GUIs. I use a Mac running OSX to write all of my code, and the problem I've encountered is that it there are deviations in appearance when the GUIs are used in windows, some of which are minor, and some of which are very significant.
1) The text in the windows version is substantially larger overall. This results in some of my button titles simply going off the button, or panel titles moving beyond the panel.
2) Axes appear to be different dimensions between Mac and Windows. i.e. An axis that appears square on my Mac will appear elongated or rectangular on windows, and vice versa.
3) Graphical displays are different. This is the real problem. Some of my GUIs use axes to display text and model chemical reaction animations. On the Mac, they look perfectly fine, but on the windows system, the sizing is completely off.
I've set all "Units" to "characters" as suggested by the Mathworks help page, and I do not specify any fonts to allow each system to use its default. I have however, specified font sizes, but apparently, 12 point font on windows appears very different from 12 point font on mac.
Are there any ways around these problems? I thought setting a specified font size and allowing for use of default fonts would fix this, but it hasn't, and I'm a little dry for ideas at this point.
Try working in 'pixels' or absolute size units instead of 'characters', and apply a scaling factor to your font sizes.
Setting 'Units' to 'characters' is probably the wrong way to go for portability, and could be the main cause of your display sizing issues. Which specific Matlab page recommended that you do so? Was it talking about cross-platform portability? The characters unit is very convenient to work with, but it is tied to the font metrics for the default system font. (See the doco for Units property at http://www.mathworks.com/help/matlab/ref/axes_props.html). That's going to differ between different operating systems. Working with 'pixels' or inches/centimeters/points, which are absolute, will probably give you more uniform results across operating systems.
And you're not wrong: OS X tends to display fonts of a given size on screen smaller than Windows does. (Generally; YMMV depending on your display DPI and system settings and other things.) For example, I run my terminals and text editors at 10 or 12 points in Windows, but 14 point or larger on Mac. So apply a scaling factor to the font sizes you set in your GUI. Figure out what looks good on Mac, and then scale it in your code to something like windows_font_size = floor(mac_font_size * 0.8) and see how it goes.
If you want to be more precise in scaling, you could grab the ScreenPixelsPerInch and ScreenSize root properties with get(0,...). You may also be able to call down in to Java code to get precise font metrics info to help with font scaling choices.
Either way, you're going to have to test your code on both systems instead of just expecting it to work portably. If you don't have ready access to a Windows development system, consider setting up a Windows VM on your Mac. With file sharing between the two sides, you'll be able to try your code out on both platforms right as you work with it.
I encountered this problem as well.
Calling this function within the FUNCTIONNAME_OpeningFcn might alleviate your issues:
function decreaseFontSizesIfReq(handles)
% make all fonts smaller on a non-mac-osx computer
persistent fontSizeDecreased
fontSizeDecreased = [];
if ~ismac()
% No MAC OSX detected; decrease font sizes
if isempty(fontSizeDecreased)
for afield = fieldnames(handles)'
afield = afield{1}; %#ok<FXSET>
try %#ok<TRYNC>
set(handles.(afield),'FontSize',get(handles.(afield),'FontSize')*0.75); % decrease font size
end
end
fontSizeDecreased=1; % do not perform this step again.
end
end

Form shrink during start up

Some weeks ago a user reported that the GUI of my program was shrink.
Today I started my laptop in multi-monitor mode and could reproduce the problem: at windows start up, the size of the main form was 325x243 pixels instead of 648x700.
I have no single line of code that controls the width/height of the form. The position is set like this: MainForm.Position:= poDefault. The user cannot resize the form ( BorderStyle:= bsSingle ).
What could cause such weirdness?
It is the second time when I start my laptop with additional monitors attached. The first time everything was ok. Could it be related to this multi-monitor configuration?
If the compiler generates no code related to form's size then it is like some external program injected code into my program to change its size. It is plausible. There are programs that are doing so in order to control how windows are spread over multiple monitors. I have one of them installed but it is not running at Windows start up.
The position is set like this: MainForm.Position:= poDefault
And that is the answer.
http://docwiki.embarcadero.com/Libraries/XE4/en/Vcl.Forms.TForm.Position
The form appears in a position on the screen and with a height and width determined by the operating system.
However there are other options like
poDefaultPosOnly: The form displays with the size you created it at design time, but the operating system chooses its position on the screen
poScreenCenter: The form remains the size you left it at design time, but is positioned in the center of the screen.
And many others.
Additionally, you may avoid fixing the issue and add a workaround instead: just set the form size fixed using http://docwiki.embarcadero.com/Libraries/XE4/en/Vcl.Forms.TForm.Constraints

Changing bash home position makes it run slowly. Any fix?

I'm having some trouble with bash. I'm changing my console's home position so I can reserve some rows in the top of the screen to print the current status of the script, and allow all the standard output to scroll in the lower part of the screen. This way, the upper lines showing the status doesn't get removed when the screen scrolls down.
I'm doing this by using these lines to do so, where <RNUM> is the number of rows I need to freeze.
\033[<RNUM>;r
\033[<RNUM>;1H
It works, however the console performance is highly lowered, it print lines really slowly (say it takes 4 times more to print the same amount of lines it usually prints).
Does anyone have a fix for the performance issue? Am I using the correct codes? I wasn't able to find any information about this stuff on the net, and I don't recall where I got these codes years ago.

Resources