本文介绍了解决办法是什么..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




它说应该避免动态分配内存,因为它会将内存分成小块并分配内存就效率而言,这是一个成本高昂的过程。那么什么是最好的解决方案

处理我们需要在运行时分配内存的情况。

问候

Mayank Jain(Nawal )


9818390836

解决方案



。使用新的




使用动态分配内存。使用新的



如何解决我的新问题。你是想用新的

代替malloc分配内存吗?

问候

Mayank Jain(Nawal)
共*************** @ gmail.com

9818390836




这取决于具体情况,在所有情况下都没有完美的解决方案可以工作

。我认为建议的是,应该尽可能地优先考虑动态自动存储。但是,人们应该知道在所有情况下都不可能使用自动存储,

事实上大多数非平凡的应用程序都会使用动态内存,

直接或间接通过容器。


对于某些应用程序,某些类型的对象需要分配并经常释放池中的
-allocator可能会增加

的表现并减少碎片的影响。


-

Erik Wikstr?m

Hi,

Its said that one should avoid dynamic allocation of memory, as it de-
fragment the memory into small chunks and allocation of memory is a
costly process in terms of efficiency. So what is the best solution to
handle to situation in which we need to allocate memory at run time.
Regards
Mayank Jain(Nawal)
co***************@gmail.com
9818390836

解决方案

using dynamic allocation of memory. use new



using dynamic allocation of memory. use new

How new is going to solve my problem. Are you trying to say use new
instead of malloc for allocating memory?
Regards
Mayank Jain(Nawal)
co***************@gmail.com
9818390836


It depends on the situation, there is no perfect solution that will work
in all situations. I think that the advice is rather that one should
prefer automatic storage over dynamic when possible. However, one should
be aware that using automatic storage is not possible in all cases, in
fact most non-trivial applications will make use of dynamic memory,
either directly or indirectly via containers.

For some applications were objects of a certain kind needs to be
allocated and deallocated frequently a pool-allocator might increase the
performance and the effects of fragmentations is lessened.

--
Erik Wikstr?m


这篇关于解决办法是什么..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 09:52
查看更多