问题标签 [defragmentation]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
1222 浏览

c++ - 在 C++ 中对数组进行碎片整理

我试图弄清楚如何做到这一点,但似乎无法理解它。

我所拥有的是一个字符数组,其中包含一些字符串,包括每个字符串末尾的空值。

像这样:

例子

我希望能够合并所有数据并在最后有一大块可用空间,但我还需要在每个字符串的末尾保存空值。

你会怎么做?

0 投票
0 回答
693 浏览

java - 使用数组编写模拟磁盘碎片整理方法,将它们改组

所以我正在尝试使用数组编写一种磁盘碎片整理方法,一个数组是文件分配表,它充当数据块的链表,另一个是指实际数据,尽管其中没有数据,只是整数值。我目前的想法是将所有值复制到 ArrayList 中,然后写回数组以将“块”打乱,这是我目前所拥有的:

到目前为止,我只是将值添加到我想用来复制它们的 Arrays/Arraylist 中,现在我只需要对它们进行洗牌以制作磁盘碎片整理方法。

0 投票
1 回答
232 浏览

c++ - 视窗。在特定逻辑集群创建新文件

相关的微软文档是: https ://msdn.microsoft.com/en-us/library/aa363911.aspx

但它描述了如何将现有的碎片文件移动到新的连续逻辑块。我想创建没有碎片的新文件。起初我通过 FSCTL_GET_VOLUME_BITMAP 获得免费的逻辑块。现在如何在具体的空闲逻辑块中写入文件?

0 投票
1 回答
112 浏览

sql - SQL Server 2012 中的索引碎片整理

我正在运行来自 SQLFOOL 和 SQL Authorities 等的不同脚本,但是当我检查数据库时,我根本看不到任何碎片整理。我写了一些代码不起作用,你能帮帮我吗?

得到错误

@table_name 附近的语法不正确

0 投票
2 回答
921 浏览

memory-management - Redis:在不重启redis的情况下释放used_memory_rss

随着时间的推移 used_memory_rss 不断增加。我理解它被填满的原因(它是内存分配器的工作方式)。但是我需要一个解决方案来释放它而不重新启动redis。

有没有办法做同样的事情?

0 投票
2 回答
252 浏览

algorithm - 以最少的更改进行碎片整理

我需要设计一种算法来进行简单的碎片整理,但具有“最小更改量”功能。假设我有 3 个容量为 10 的容器,其中包含以下物品:

所有的容器都装满了 8/10。现在我想放置下一个大小为 3 的项目 - 总可用容量为 6,但没有一个容器的可用容量为 3。虽然有多种可能的碎片整理解决方案,但我需要算法,它会找到解决方案,其中第一个容器中大小为 2 的项目将被放置在其他地方,因此新项目可以然后放置到容器 1 中,因为此解决方案只需要进行一次更改(而不是替换容器 3 中的两个项目)。所以所需的结果应该是:

我已经做了一些研究,我只能找到背包问题或好友算法,但我不确定这些是否真的是我想要的。

你们中的任何人都可以帮助我尽可能简单地设计这个算法吗?我正在解决一种情况,即我将有少量的大型容器和大量的物品,因此列举所有可能性并不是最优的。

非常感谢!

更新只是为了弄清楚我在问什么-确定是否可以通过仅进行一项更改来解决这种情况是没有问题的。问题是,当“单步走”不可能时,如何找到最少的替换数量。

0 投票
0 回答
76 浏览

wpf - 在 WPF 中运行进度条和磁盘碎片整理

我正在开发一个用于硬盘碎片整理的 exe。为此,我使用 接口StartDefragmentation(String DeviceName)方法对IDefragmenter硬盘特定驱动器进行碎片整理。

它工作正常,但我还必须运行进度条来显示碎片整理的状态,但我不知道完成特定驱动器的碎片整理需要多少时间。如果我知道下一个线程所花费的实际时间,那么我将轻松设置进度条 Value 和 Maximum 属性。

我的代码:

我已经使用了这段代码,但它对我没有帮助:

0 投票
1 回答
1272 浏览

c - Defragment Memory Blocks in C Memory Pool

I've built a simple memory pool in C and I've also implemented the ability to implement memory blocks in this pool.

The memory blocks themselves are quite simple, just a doubly linked list with a free flag and size property.

What I'm trying to do now is create a function that takes a pointer to my memory pool and defragments the memory blocks inside so that allocated (free == 0) blocks are towards the beginning of the pool and deallocated blocks are towards the end of the pool.

For example, if I had the blocks of memory structured like this before I called my defragment function:

Then after calling my function the blocks would be arranged like so:

I've attempted to build the function already however I've ran into a problem with moving the correct blocks around it seems as this is my output after the function is called:

I'm not certain at all where the function is performing the incorrect operations so hopefully someone can shed some light on this for me.

My defragment function:

The call to the initBlock function just takes a memory address, treats it as a Block structure, then sets the free property to true and the size property to the given size.

I'm using the GCC compiler with the -std=C99 flag.

0 投票
2 回答
2603 浏览

c# - 强制 .NET GC 压缩或整理第 2 代堆?

我们在 .NET 框架中使用 C# 编写了一个 Windows 服务,几个小时后我们注意到第 2 代堆的大小变得异常。大部分空间都是免费的,dotMemory Profiler 向我们展示了这一代我们有大约 90% 的碎片。如何强制 .NET GC 压缩这个空间?这意味着 GC 可以释放这个空间,但它不能压缩它以供进一步使用。

0 投票
3 回答
1990 浏览

python - 使用 Python 脚本进行磁盘碎片整理和磁盘清理

你能帮助我如何使这个脚本工作。

对于碎片整理

用于磁盘清理

尝试此脚本后,它没有做任何事情,也没有错误消息提示。谢谢你。