存储数组值直到下次调用方法 [英] store Array values until next time method called

查看:55
本文介绍了存储数组值直到下次调用方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨。

有谁知道我怎么能把一个没有管理的阵列装箱,而且它不会丢失他的内容。

我的问题是:

我有一个返回托管数组的方法,我想存储它,但我不能将它存储在CollectionBase列表中,因为系统抛出异常堆栈溢出,我的方法在timer_tick中调用。

有谁知道我怎么能存储那个数组直到下一个比较它们呢?

谢谢

解决方案

< blockquote>我希望你需要在堆而不是堆栈上创建数组。堆栈内存通常是有限的。

展开 | 选择 | Wrap | 行号


我的问题是我想存储矩阵的值然后当我重复那个方法时,我希望再次使用它们并从新矩阵中减去它们。就像;

方法(MatrizIPF)

MatrizIPF [i,j] = a;

MatrizINPF [i,j] = 0;


MatrixA = MatrizIPF;

返回MatrizIPF


然后再次调用方法

和做


MatrixA-MatrixIPF;


MatrixA = MatrixIPF;

RETURN MatrizIPF;


更多或更少



堆栈内存通常是有限的。



我现在已经看过你这几次(各种各样的伪装)。但是根据我的经验,如果堆栈空间有限,那么堆空间也是如此(即在嵌入式平台上),如果堆空间没有特别限制,那么堆栈空间也不是(在Windows平台上)。我承认在这方面我不了解* nix平台。这似乎源于两者都是从可用RAM(在某些情况下是物理和虚拟)分配的事实,因此这些段中的空间最终都取决于平台上可用的RAM量并具有类似的限制。


虽然我已经看到一些有趣的论据,关于从堆栈或堆中分配是否更好,但在我看来因为堆栈空间比堆空间更有限。不是特别好。


Hi.
Does anyone know how can i crate an Array not managed, and it doesn''t looses his contents.
My problem is:
I''ve a method that returns a managed array and i want to store it but i can''t store it in a CollectionBase List cause the system throws me an exception stack overflow, my method is called in timer_tick.
Does anyone know how can i store that array until the next tick to compare them?
thanks

解决方案

I expect you need to create the array on the heap rather than the stack. Stack memory is often limited.

Expand|Select|Wrap|Line Numbers


My problem is that i want to store the values froma a matrix that are xomputed in a method then when i repeat that method i want to have them avaiable again and subtract them from a new matrix. is like;
method(MatrizIPF)
MatrizIPF[i,j]=a;
MatrizINPF[i,j]=0;

MatrixA=MatrizIPF;
return MatrizIPF

and then call again the method
and do

MatrixA-MatrixIPF;

MatrixA=MatrixIPF;
RETURN MatrizIPF;

IS THIS MORE OR LESS


Stack memory is often limited.

I''ve seen you say this a few times (in various guises) now. However in my experience if stack space is limited then so is heap space (i.e. on an embedded platform) and if heap space is not particularly limited then neither is the stack space (on the Windows platform). I admit I have no knowledge of *nix platforms in this regard. This seems to stem from the fact that both are allocated from available RAM (physical and virtual in some cases) and therefore space in these segements are both ultimately dependent on the amount of RAM available on the platform and have similar limits.

While I have seen some interesting arguments on whether it is better to allocate from the stack or heap it appears to me that "because stack space is more limited than heap space" is not a particularly good one.


这篇关于存储数组值直到下次调用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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