问题标签 [shared-memory]

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 投票
5 回答
6785 浏览

c++ - Anyone have a good shared memory container for C++?

I've long had a desire for an STLish container that I could place into a shared memory segment or a memory mapped file.

I've considered the use of a custom allocator and placement new to place a regular STL container into a shared memory segment. (like this ddj article). The problem is that STL containers will internally have pointers to the memory they own. Therefore, if the shared memory segment or memory mapped file loads at a different base address (perhaps on a subsequent run, or in a second process), then the internal pointers are suddenly invalid. As far as I can figure out, the custom allocator approach only works if you can always map the memory segment into your process at the same address. At least with memory mapped files, I have lots of experience of that NOT being the case if you just let the system map it where ever it feels like.

I've had some thoughts on how to do this, but I'd like to avoid it if someone else has already done the work (that's me, being lazy).

I'm currently leaving locking out of the discussion, as the best locking strategy is highly application dependent.

0 投票
6 回答
4157 浏览

coldfusion - 何时应该在 ColdFusion 中使用范围锁定(应用程序、服务器等)与命名锁定?

什么时候适合使用 <cflock scope="application"> 或类似的,而不是 <cflock name="foo">?

具体来说,我有兴趣使用 CFLock 保护应用程序、会话或服务器范围内的共享对象,但我也有兴趣了解 ColdFusion 中锁定的不同用途。

0 投票
1 回答
393 浏览

coldfusion - 何时在应用程序范围内使用锁定

我想知道是否需要锁定在应用程序范围内创建的一些代码。如果我在应用程序范围内创建一个对象说 userDAO.cfc,那么它可用于所有页面。然后,如果我在该对象中有一个方法说 getUserInfo(userID) 将在应用程序的不同部分调用,我是否需要锁定此方法?

0 投票
2 回答
89715 浏览

shared-memory - 在 Linux 中使用 ipcrm 删除共享内存

我正在使用共享内存应用程序,并使用以下命令删除段:

但我不知道我是否做对了,因为当我运行时,ipcs我看到相同的段,但密钥为 0x0000000。那么内存段真的被删除了吗?当我多次运行我的应用程序时,我会看到带有密钥 0x000000 的不同内存段,如下所示:

实际发生了什么?内存段真的被删除了吗?

编辑:问题是 - 如下面接受的答案所述 - 有两个进程使用共享内存,直到所有进程都关闭,内存段不会消失。

0 投票
6 回答
38509 浏览

.net - 如何在 .NET 中实现共享内存?

我有一个 C++.NET 应用程序和一个 C#.NET 应用程序。我希望他们通过共享内存进行通信。

.NET 2.0 版怎么可能?

主要是想共享一个队列对象。

0 投票
1 回答
12851 浏览

windows - 在 Windows 中查看共享内存的程序?

我正在寻找一个程序来查看和浏览 Windows x32/x64 中的(本地)共享内存。

我知道这是存在的,因为我之前已经在行动中看到过它。出于某种原因,谷歌和 MSDN 在这方面让我失望了。

0 投票
3 回答
3412 浏览

c - 如何使多个`fork()`-ed 进程使用共享内存进行通信?

我有一个有 5 个子进程的父进程。我想向每个子进程发送一个随机变量。每个孩子将平方变量并将其发送回父母,父母将把它们加在一起。

这甚至可能吗?我想不通...

编辑:此过程将使用共享内存。

0 投票
2 回答
2625 浏览

php - 使用与 php 和 c 的共享内存?

可以在windows中使用共享内存在php脚本和c程序之间进行通信吗?

c 程序一直运行并使用内存映射文件,即:

对于 PHP 脚本,我可以只使用以下代码打开 c 程序创建的内存映射文件吗?

还是c内存映射文件和php共享内存不同?

0 投票
6 回答
16353 浏览

c++ - 在 Windows 下使用共享内存。如何传递不同的数据

我目前尝试使用 Windows CreateFileMapping机制来实现一些进程间通信。我知道我需要先用 CreateFileMapping 创建一个文件映射对象,然后再用 MapViewOfFile 创建一个指向实际数据的指针。然后,该示例使用 CopyMemory 将数据放入映射文件。

在我的应用程序中,我有一个图像缓冲区(1 MB 大),我想将其发送到另一个进程。所以现在我查询一个指向图像的指针,然后将整个图像缓冲区复制到映射文件中。但我想知道这是否真的有必要。难道不能只在共享内存中复制一个指向图像缓冲区数据的实际指针吗?我尝试了一下,但没有成功。

0 投票
1 回答
130 浏览

c++ - 我担心由于使用对象的方式,这段代码没有做我想做的事情

我有以下代码,我想知道是否有人可以帮我看一下。

我有一个多线程应用程序,它们都共享一个对象并对其进行操作。我创建了一个指向它的某个元素的指针,这样我就不必每次都输入长路径,但我担心它可能只是修改共享对象的副本,而不是共享对象对象本身。

这是代码:

这是有效的还是只是在修改副本?