内存使用情况。 [英] Memory usage.

查看:88
本文介绍了内存使用情况。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序,每50ms生成一次自定义bimap。这很慢,但没办法让它更快。

现在我想让它尽可能快地生成(这是50毫秒)。

但我必须将这些图像存储在某个地方。

我能想到的唯一地方是ram。

这么多位图对内存使用有多大影响(可能是数万个)。 />
我想象它的内存使用是不可能的。我错了吗?

内存中的一个位图对象有多大?

如果我使用Image对象会有所不同吗?


非常感谢任何帮助。

谢谢。

Nick Z.

解决方案

< blockquote> Nick< pa ***** @ optonline.net>写道:

我有一个程序,每50ms生成一次自定义bimap。这是慢的,但没办法让它更快。
现在我想让它尽可能快地生成(这是50
ms)。
但我必须将这些图像存储在某处。
我唯一能想到的地方是ram。




为什么不将它们存储在磁盘上?如果你有一个线程创建位图和

一个线程将它们写入磁盘,并且它们之间有一个队列,我就不会认为你已经有了b $ b很多问题。


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet

如果回复小组,请不要给我发邮件


Jon Skeet [C#MVP]写道:

Nick< pa ***** @ optonline达网络>写道:

我有一个程序,每50ms生成一次自定义bimap。这是慢的,但没办法让它更快。
现在我想让它尽可能快地生成(这是50
ms)。
但我必须将这些图像存储在某个地方。
我唯一能想到的地方是ram。



为什么不将它们存储在磁盘上?如果你有一个线程创建位图并且一个线程将它们写入磁盘,并且它们之间有一个队列,我就不会认为你会遇到太多问题。




好​​吧我认为这需要太长时间。

你能用两个线程和它们之间的队列来解释你的意思吗?

两个程序在运行?或者你的意思是超线程?我不是你可以说的专业人士。


谢谢你。

Nick Z.


Nick < PA ***** @ optonline.net>写道:

为什么不将它们存储在磁盘上?如果你有一个线程创建位图并且一个线程将它们写入磁盘,并且它们之间有一个队列,我就不会认为你会遇到太多问题。



好吧我觉得这需要太长时间。
你能用两个线程和它们之间的队列来解释你的意思吗?
两个程序在运行吗?或者你的意思是超线程?我不是专业人士你可以告诉你。




我的意思是同一个进程中只有两个线程。请参阅
http://www.pobox.com/ ~subet / csharp / multithreading.html


你想要使用两个线程,这样一个人就可以做IO而

另一个是自己生成图像。您可能希望将队列的大小限制为
,这样如果生成线程太远了,那么你可以等待IO线程赶上一点相比

比继续生成并且可能内存不足。


-

Jon Skeet - < sk ** *@pobox.com>
http://www.pobox.com/~双向飞碟

如果回复小组,请不要给我发邮件


I have a program that generates a custom bimap every 50ms. Which is slow, but no way to make it faster.
Now I want to keep it generating as fast as possible (which is 50 ms).
But I have to store these images somewhere.
The only place I can think of is ram.
What effect would so many bitmaps have on memory usage (maybe tens of thousands).
Im imagining it memory usage would be unaccaptable. Am I wrong?
How big is one bitmap object in memory?
Would it make a difference if I use an Image object?

Any help is greatly appreciated.
Thank you.
Nick Z.

解决方案

Nick <pa*****@optonline.net> wrote:

I have a program that generates a custom bimap every 50ms. Which is
slow, but no way to make it faster.
Now I want to keep it generating as fast as possible (which is 50
ms).
But I have to store these images somewhere.
The only place I can think of is ram.



Why not store them on disk? If you have one thread creating bitmaps and
one thread writing them to disk, with a queue between them, I wouldn''t
have thought you''d have too many problems.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Jon Skeet [C# MVP] wrote:

Nick <pa*****@optonline.net> wrote:

I have a program that generates a custom bimap every 50ms. Which is
slow, but no way to make it faster.
Now I want to keep it generating as fast as possible (which is 50
ms).
But I have to store these images somewhere.
The only place I can think of is ram.


Why not store them on disk? If you have one thread creating bitmaps and
one thread writing them to disk, with a queue between them, I wouldn''t
have thought you''d have too many problems.



Well I thought it would take too long.
Could you please explain what you mean by using two threads and a queue between them?
Two programs running? Or do you mean hyper threading? Im no pro as you can tell.

Thank you.
Nick Z.


Nick <pa*****@optonline.net> wrote:

Why not store them on disk? If you have one thread creating bitmaps and
one thread writing them to disk, with a queue between them, I wouldn''t
have thought you''d have too many problems.



Well I thought it would take too long.
Could you please explain what you mean by using two threads and a
queue between them?
Two programs running? Or do you mean hyper threading? Im no pro as
you can tell.



I mean just two threads in the same process. See
http://www.pobox.com/~skeet/csharp/multithreading.html

You''d want to use two threads so that one would be doing the IO while
the other was generating the images themselves. You might want to limit
the size of the queue so that if the generation thread got too far
ahead, you could just wait for the IO thread to catch up a bit rather
than keeping on generating and potentially running out of memory.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


这篇关于内存使用情况。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆