g*****9 发帖数: 349 | 1 这是神马概念?5个pending reallocation count,速度变得巨慢。这就是所谓的TLER
。。。
以后再也不买红盘,倒是希捷没有出过问题。 |
|
|
|
E***e 发帖数: 3430 | 4 如果不用RAID
出现第一个reallocation的时候及时预警还是很有帮助的吧? |
|
E***e 发帖数: 3430 | 5 本来说一个pending reallocation
盘慢的要死
结果做了个随机fill
坏到没了
硬盘一切如常
这他毛的怎么回事?
我可不想继续用这个盘啊
可是别寄了RMA再给我退回来 |
|
M********t 发帖数: 5032 | 6 你水鸡fill导致sector reallocated了,他们可以查出来的。 |
|
E***e 发帖数: 3430 | 7 我也是这么想的
可是reallocated count怎么也是0?
明明有一个坏道了
然后怎么搞搞无声无息的又没了
这样的S.M.A.R.T.不算作弊?
我反正不着急寄
低格中看看能不能再搞出来 |
|
M********t 发帖数: 5032 | 8 也许那个sector一开始读不出,后来写了一遍又可以读出了,所以就不用reallocate |
|
L***s 发帖数: 1148 | 9 查一下 0x05 Reallocated Sectors Count
如果碰到坏扇区重映射了,应该大于零 |
|
n*********u 发帖数: 1030 | 10 感觉白标的好像会少100G左右,
红盘在smart里看是完美的,白盘有三个reallocated sector,可用空间也稍微小一点。
还有就是白盘会睡眠红盘不会。
但是考虑到价格优势,还是值的。 |
|
h****6 发帖数: 229 | 11 You may use System rescue to reallocate your disk. Don't change your
partition containing XP.
use run_qtparted to launch the program. |
|
W*****x 发帖数: 684 | 12 $ cd geoip-api-c-master
$ libtoolize
$ aclocal
$ autoconf
$ automake --add-missing
$./configure
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
... 阅读全帖 |
|
o******r 发帖数: 259 | 13
I tried with following code. It works without problem.
class A {
public:
int i;
};
class B : public A { }; // definitions of classes, these are OK
void Foo() {
A & a = B(); // ??
a.i = 1;
cout << a.i<
A * p = &B(); // ??
p->i = 2;
cout << p->i<
}
reallocate a memory block with size 1020?
use new instead?
这样放狗查一下就知道了,估计没多少人用过
好象在哪见过用函数指针转换的 |
|
t****t 发帖数: 6806 | 14 1. search yfh的post,里面有一样的问题(虽然不是他问的)
2. realloc
3. placement new没错
4. 查查书就有了.void * operator new(std::size_t size, void* ptr) throw();
注意你不能overload这个.这个函数其实什么也不做.
5. 在多重继承的子类里,所有同类的virtual base只有一个copy,非virtual的,出现几次
就有几个copy.virtual base用来做interface很不错.
6. 如果不用extern "C",那link时就找不到对应的函数,因为c++版的函数名被decorate
过了 |
|
t******t 发帖数: 51 | 15 OK, my answers:
1) A & a = B(); // does not compile, need to use const on the left hand side
A * p = &B(); // does compile, problem is: 'B()' is a temporary, so we
cannot use p after this line of code as the memory is released
2) realloc();
3) placement new
4) try Effective C++ (or More effective C++?), forgot which item but there
are several items about this topic
5) try any C++ book
6) name mangling issue
Bottomline is: if you really read through the two books Effective C++ and
More effective |
|
|
|
j****r 发帖数: 28 | 18 没有内存泄漏。
可以用realloc来resize内存大小? |
|
x****u 发帖数: 473 | 19 How to rename a variable in Matlab using one command without reallocating
memory?
Thanks a lot! |
|
P********e 发帖数: 2610 | 20 你前面temp能是create on heap
private destructor 能保证instance ONLY on HEAP
如果要STACK的话,overload operator new/delete as private, 其实严谨一点
malloc, alloc, realloc都要overload
你的方法是在heap上 |
|
l*****c 发帖数: 1153 | 21 竟然被强迫用JAVA,唉。
怎么样reallocate一个指定长度的String?我需要对一个output String做大量的
append操作(Million级别),需要尽可能的efficient的来做。最终String的总长度是
事先知道的。所以照C++来说,当然是preallocate space然后往里填效率高。 |
|
d******a 发帖数: 238 | 22
c中, realloc函数实现动态数组的扩大,经常2倍增长。 |
|
b***y 发帖数: 2799 | 23 ☆─────────────────────────────────────☆
miis (miis) 于 (Tue Jul 29 20:47:37 2008) 提到:
实际上这个问题知道了很久了。只是一直用起来没差别所以就没当回事。
有很多windows平台上比较老的c++ code都用这些语句拿memory。
C到是有realloc。。。
可是用它和用new好像没有任何差别,而且现在的code也不大用Alloc。。
哪位大虾给讲讲这里面的历史?
☆─────────────────────────────────────☆
microbe (纵使相逢应不识) 于 (Tue Jul 29 21:01:59 2008) 提到:
Not much difference unless you are programming on 16-bit Windows.
☆─────────────────────────────────────☆
miis (miis) 于 (Tue Jul 29 21:07:32 2008) 提到:
谢谢!
所以这是所谓的历史遗留 |
|
|
X****r 发帖数: 3557 | 25 以下程序没测试过,仅供参考。
/**
* @param input The input file.
* @param size A pointer to store result size.
* @return The pointer to the result data,
* or NULL for not enough memory.
*/
int *read_all(FILE *input, int *size) {
int n = 128, i;
int *data = (int *)malloc(n * sizeof(int));
for (i = 0; data && fscanf(input, "%d", data + i); i++) {
if (i == n) {
data = (int *)realloc(data, (n *= 2) * sizeof(int));
}
}
if (size) {
*size = i;
}
return data;
} |
|
p***o 发帖数: 1252 | 26 Get a C book. You won't learn C from BBS.
BTW, the function f(char **p) looks quite suspicious.
It sounds to me it want to do some tricky things like
freeing *p following by allocating another buffer and
passing it outside, pretty much realloc. It will get
into serious problem if you pass in an array in this
case. |
|
r****t 发帖数: 10904 | 27 我也遇到类似情况,尺寸小的 video 文件做输入运行就完全正常,尺寸大点的就
crash 了,或者是 malloc assertion error, 或者是月realloc error, double free 什么的每次运行还不一样。 靠 log 把问题缩小到一个 api call 上面,comment 掉就没问
题了,或者手动在此只处理一个 frame 的一部分,只要总尺寸还比较小也没有问
题。 之后就不知道该怎么办了。valgrind 也没发现啥明显的。
现在 feature set 还不全,都是 plugin 结构的,我估计几天以后完成另外一个
plugin 以后要回头来 debug 这个, 痛苦。
static
to |
|
d****p 发帖数: 685 | 28 the reason why your second x[0] yields 0 is the reserve operation
reallocated memory for your vector and thus &x[0] changed. Since the length
of the vector is still 0, the first value (5) won't be copied to new
location.
If you use push_back and reserve, the &x[0] will change too; but the
implemention however will copy the value of the 1st element to the new
location.
So |
|
F*******i 发帖数: 190 | 29 so that I can rebind the malloc, realloc, free?
thanks a lot! |
|
d****n 发帖数: 1637 | 30 又拓展了一下,给出parent link和buffed level computation
#include
#include
int *buff=NULL;
int buff_size=1024;
int buff_used=0;
int level(int query ){
while( buff[buff_used-1]
{
if ( buff_size <=buff_used ){
buff_size<=1;
buff=(int *)realloc( buff,sizeof(int)*buff_size );
}
buff_used++;
buff[buff_used]=(buff_used+1 )*(buff_used+1+1)/2;
}
... 阅读全帖 |
|
d****n 发帖数: 1637 | 31 献丑了,have fun!
#include
#include
#include
#include
#define IS_WHITE_SPACE(c ) ( isblank((c)))
char * replace_white_space( const char *source, size_t source_len){
size_t used=0, inc=0, allocated=source_len+1;
char *ret= (char *)malloc(sizeof(char)*allocated );
const char *s=source;
while(*s++){
(IS_WHITE_SPACE (*(s-1)))? (inc=3):(inc=1);
if ((used+=inc)>=allocated)
ret=(char *)realloc(ret, sizeof(char)*(alloc... 阅读全帖 |
|
z********i 发帖数: 568 | 32 个人观点,没有测试。
1. isblank returns true for both blank and tab.
2. for "const char *source", source can be modifed. So no need of "const
char *s".
3. since source_len is given, "while(*s++)" is not good, may have
segmentation fault if the parameters are not correct.
4. the way of memory allocation(double at each reallocation) is not space
efficient.
5. "used" is never increased in the loop.
知道memcpy,常常想不起来用它。见这程序用了,所以觉得有意思。 |
|
l*********s 发帖数: 5409 | 33 what is the purpose? to save memory? can't do realloc? |
|
S*********g 发帖数: 5298 | 34 Instead of
for ti=1:10
a(end+1)=ti;
end
matlab will have to reallocate and create a new list every time
. The code will become slower and slower as you ti gets larger. The cost is
hyper linear in the size of your loop
Use:
a(10)=0;%this will allocate memory
for ti=1:10
a(ti)=ti;
end
Dynamic array is evil.
★ 发自iPhone App: ChineseWeb 7.8
★ 发自iPhone App: ChineseWeb 7.8 |
|
c******o 发帖数: 1277 | 35 first we need to ask why we have heap and stack, obviously you can implement
one using the other.
they just different, and stack is faster mostly if you are ok with its cons
copy from else where:
Stack
very fast access
don't have to explicitly de-allocate variables
space is managed efficiently by CPU, memory will not become fragmented
local variables only
limit on stack size (OS-dependent)
variables cannot be resized
Heap
variables can be accessed globally
no limit on memory size
(relatively) sl... 阅读全帖 |
|
d******3 发帖数: 70 | 36 两个都有隐患。
1会reallocate,造成浪费。
2的问题就更多了。difficult to manage,not safe,etc
比较好的方法是:
std::vector vecp;
想更安全点的话这样:
std::vector< unique_ptr > vecp;
或:
std::vector< shared_ptr > vecp; |
|
a*********a 发帖数: 3656 | 37 觉得这个逃不过O(N),如果你要继续优化,只能从inner loop着手了。粗略看一下,可
能有一两个地方。要肯定,还是得上profiler,数instruction fetch.
1. while ((posNext = whole.find(',', posCurrent))
如果你自己用一个char*纪录在whole里的位置,可以避免find每次寻找posCurrent,我
估计是省掉一个指针加法。find()应该是先从whole的头进到posCurrent,然后步进找'
,',这其中的第一步应该没有必要。
2. loop里面没有必要每次取elementStr = substr(...),再加到partialString. 你的
code里没法保证没有多次的copy。如果partialString没有reserve够,可能还会有heap
realloc.
可以先找到start, stop position, 然后loop外做一次性substr。这样,可能还可以免
掉后来的erase。
这样下来,loop里面应该只有指针操作和字符比较。没有任何string操作。
68,
inpu... 阅读全帖 |
|
T********i 发帖数: 2416 | 38 哪有那么简单?只allocate不free是最底层的。上层的有能free的。
比如我最常用的binary allocator。每次都把size round up to nearest 2 n次方。这
样free都到一个free list里面,allocate先查free list。内存利用率低一点。但是保
证allocate和free都是纳秒级。
其它的各种allocator多了,比如object pool等等等等。有些我甚至都没看到其他人用
过。有很多都是自己拍脑门搞出来的。
有研究表明,一般而言一个server进程的70%-90%执行时间都消耗在memory management
上。因此,优化还是有必要的。
当然你可以argue有时free和allocate是上层比如STL vector reallocarlte导致的。随
后的memory copy更消耗时间。其实,很多时候我们可以保证reallocate不发生。但是
我们仍然有动态内存管理的需求。 |
|
d****n 发帖数: 1637 | 39 你要是看过了就会更明白不会再问了。
append arrayList by make
malloc+realloc
what is your answer? |
|
f********t 发帖数: 6999 | 40 【 以下文字转载自 Military 讨论区 】
发信人: aichitang (aichitang), 信区: Military
标 题: 两年前面过一次LinkedIn,经历过的最傻逼的一次面试
发信站: BBS 未名空间站 (Fri Feb 5 23:02:26 2016, 美东)
电话面试,一个美国英语,另一个应该是明显的中国口音吧。
题目很简单,给一个字符串写出所有的permutation,我几分钟写出来了,就是一个简
单的递归搜索,总共不超过30行,我用c++写的。结果面试的老中没看懂,让我拿例子
讲一遍,我拿个简单的例子讲完了他还是看不懂。我当时蒙了,我说好,我再给你写一
个版本的,我就把一个终止条件展开写了,具体我忘了。大概就是把他不明白的地方重
写了一遍,结果他还是没看懂。我当时有点纳闷,不至于啊,我于是写了第三个版本,
用一个set保存所有已经搜索过的词,他终于看懂了。
然后最傻逼的事发生了,他大概好像说了你前两次都没写对,第三次写对了,具体我忘
了。草,当时我就火了,我说我前两次写的是因为你看不懂,你怎么能说是我写错了呢
?我前两次写的效率高,还简洁,是你看不... 阅读全帖 |
|
p***o 发帖数: 1252 | 41 C语言一个realloc就要搞死不少人 ... |
|
|
g*s 发帖数: 12 | 43 Here are two approaches to handling an input
file of arbitrary size:
A. Use a library or syscall that lets you determine the size
of the file. malloc a buffer to be that size. Then read
chars into the buffer until you hit EOF.
B. Malloc a buffer of a specific size. Read chars until
you hit that size, or EOF. If you fill the buffer,
use realloc to get a larger buffer.
From a security perspective, which is better? Why?
谢谢 |
|
b******i 发帖数: 59 | 44 if you want to join Big 4 Canada offices, I'd say CGA will not help you much
except if you want to do small business in those offices.
which city are you going to reallocate? which practice you want to join? |
|
l********e 发帖数: 413 | 45 The statement is not very true. Accounting involves numerous estimatations of
future events, so there's large room to manipulate, or to reallocate
resources. Accounting choices could influence future significantly.
finance
for |
|
h*******l 发帖数: 359 | 46 我说的方向对是指对目前经济形式的判断。年初的时候中央还不清楚方向,很多人觉得
人民币应该升值,来解决顺差问题和由冲销带来的货币供应上升。本版当时还讨论过这
个话题。那时我就非常不以为然,这些说法从理论上讲是对的,但是忽视了中国的具体
情况。
昆山,温州,东莞的企业我都去看过,那里做的很多本质上都是国际产业链上切下来的
很小的一块,两头在外,跟上下游都没有bargain power,净利润非常薄,大概5-10%
,就靠上规模,所以那里民间信贷特别发达,因为你不把规模做上去你就完蛋。所以有
些厂外面看上去就像一个个军营。但是杠杆大了其实非常危险。人民币升值很容易把那
点利润扫掉,然后信贷链断掉产生连锁效应。
如果光看书的话大概觉得创造性毁灭很重要,但是你要是去那些地方看过就不觉得了,
因为那里的厂的productivity heterogeity其实很小的,reallocation的效果很小。而
且那些厂最重要的是什么,两头在外,是老板的network,这个流动性最大了。但是那
些厂对于刚从农村的民工出来真的很重要,农村多封闭,但是在军营一样的厂里呆上两
年,接触的人多了,状态马上不一样了 |
|
a*****a 发帖数: 1038 | 47 It is entertaining to read through all posts in this thread. PM does not
need to be an expert on this project. Hr or she needs to know who should be
in his/her team, develop all tasks and budget hours to team members, and
keep 10-15% profit as target goal for PM. As a good PM, internally, he/she
has to stay in the scope of work and delivery schedule, control the budget,
and reallocate money from one to another task. Externally, he/she has to
communicate with clients and send clients' feedbac |
|
g****i 发帖数: 2269 | 48 http://travel.state.gov/visa/frvi/bulletin/Visa_Bulletin_For_January_2007.html
All schedule A: 15JUN04
D. SCHEDULE A WORKER VISA CATEGORY
A small amount of Schedule A Worker numbers which had been provided to
consular offices for November use were returned unused after the end of the
month and thus became available for reallocation. All remaining Schedule A
Worker numbers have been made available to applicants whose priority dates
are within the January cut-off date (15JUN04). The Schedule A Wor |
|