2
Problem
I am having problem in my program that when the process reaches more than 1.5 GB of memory usage the process stops running and displayed an error of OutOfMemory
.
In my process I’m reading a file .AVI
and storing each frame in one Array de Bitmaps
,
so that I can run later on a player in a synchronized way.
Doubt
I don’t know if Windows limits a array
a 1.5 GB and so it triggers a memory error even having enough space to continue. Someone has had this problem and knows some solution?
Additional information
There are 4 files in 30FPS
sized 7MB
each.
My computer is 64Bits
, Windows 7
, 8 GB de memória
.
Video files, as far as I know, are compressed to the extreme. You’re not copying bitmaps, you’re converting enough compressed information from each frame to a format millions of times larger (I’m not exaggerating when I say millions). Surely there must be better ways to achieve your goal, if what you want is timing.
– Oralista de Sistemas
I suggest opening another question by saying what is your biggest problem (sync video and audio, maybe?). Maybe someone will get a solution otherwise.
– Oralista de Sistemas
@Renan obg for the quick response. So I’m doing it this way because I can better control the player. Ex: I can choose the exact point I want from the video. But this my question serves tb to other applications that use array that ends up getting mt large and passing the size of 1.5GB. I’ve had that kind of trouble on another show. I would like to know if you have any solution or way to solve this and increase the maximum array size.
– Rafael Souza
I don’t understand these techniques, but I think you should use some kind of buffer (every player uses it). Loading all these frames in memory at once is very inefficient.
– cvbarros
Storing ALL video data in memory may not be a good output because even if your program manages to address it there will be an underutilization of the memory. Why don’t you read the data in pieces (say, every 100 frames)? If you already know how to interpret the format (codec) of the video, "skip" to a given frame is simply to make a
FileStream::Seek
in the file for position i * s (where i = frame index from 0 to n and s = frame size in bytes).– Luiz Vieira
@Luizvieira I’ll try to do it this way ! I think it will be the best way. Obg :)
– Rafael Souza
Not at all. : ) Anyway, your question seems a little broad. From the comments you can infer that your problem is reading and playing the data from a video file, but the question seems to be about memory addressing limits in matrices in C#. If you’re going to keep this doubt, you might want to edit the question to at least include an example of succinct code (and easily playable).
– Luiz Vieira
Rsouza, if you want I can rephrase the question for you, considering what has already been discussed. And then you add more information if necessary.
– bfavaretto
Although the documentation is a bit confusing about this, an Outofmemoryexception occurs when there is no contiguous memory block available for the process with the desired dimension.
– Paulo Morgado